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.

相关文章

1. 如何去重 #!/usr/bin/perl use strict; my %hash; while(...
最近写了一个perl脚本,实现的功能是将表格中其中两列的数据...
表的数据字典格式如下:如果手动写MySQL建表语句,确认麻烦,...
巡检类工作经常会出具日报,最近在原有日报的基础上又新增了...
在实际生产环境中,常常需要从后台日志中截取报文,报文的形...
最近写的一个perl程序,通过关键词匹配统计其出现的频率,让...