微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Perl system()调用会死吗?

可以在Perl 5中使用system()调用吗?

(换句话说,为了100%防止执行system()调用的程序,是否需要将其包装到eval块中,还是完全没必要?)

我没有在perldoc system中找到这种可能性,但没有找到准确的“这个呼叫永远不会死”.

注意:问题是关于这里的基本CORE Perl,没有autodie或任何其他具有类似效果自定义模块.此外,假设没有设置ALRM信号,或者任何其他自定义信号处理程序.

我假设Perl 5. *的所有版本都表现相同,但如果没有,则可以理解与5.8相关的答案.

解决方法

除非我对源代码的解释不正确,否则这似乎是一种可能性:

来源:PP(pp_system)代码块中的Perl 5.16.2(也检查5.8.8),文件:pp_sys.c,行:4224:

if (n != sizeof(int))
  DIE(aTHX_ "panic: kid popen errno read,n=%u",n);

DIE是在util.c中声明的Perl_die(pTHX_ const * pat,…)

根据文件,“恐慌:孩子popen errno读”意味着“分叉的孩子返回了一个关于其错误的难以理解的消息”.

Explanation of panic messages in Perl

The convention is that when the interpreter dies with an internal error,the message starts “panic: “. Historically,many panic messages had been terse fixed strings,which means that the out-of-range values that triggered the panic are lost. Now we try to report these values,as such panics may not be repeatable,and the original error message may be the only diagnostic we get when we try to find the cause.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐