- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我试图解开我在 perlipc 中看到的东西文档。
If you're writing to a pipe, you should also trap SIGPIPE. Otherwise, think of what happens when you start up a pipe to a command that doesn't exist: the open() will in all likelihood succeed (it only reflects the fork()'s success), but then your output will fail--spectacularly. Perl can't know whether the command worked because your command is actually running in a separate process whose exec() might have failed. Therefore, while readers of bogus commands return just a quick end of file, writers to bogus command will trigger a signal they'd better be prepared to handle. Consider:
open(FH, "|bogus") or die "can't fork: $!";
print FH "bang\n" or die "can't write: $!";
close FH or die "can't close: $!";
That won't blow up until the close, and it will blow up with a SIGPIPE. To catch it, you could use this:
$SIG{PIPE} = 'IGNORE';
open(FH, "|bogus") or die "can't fork: $!";
print FH "bang\n" or die "can't write: $!";
close FH or die "can't close: status=$?";
open
上爆炸不管我是否有 $SIG{PIPE} 行,都带有“无法 fork :没有这样的文件或目录”。
最佳答案
这是在 5.6 的开发过程中实现的更改,以便 system() 可以检测何时无法 fork/exec 子项
https://github.com/mirrors/perl/commit/d5a9bfb0fc8643b1208bad4f15e3c88ef46b4160
它也记录在 http://search.cpan.org/dist/perl/pod/perlopentut.pod#Pipe_Opens 中
它本身指向 perlipc,但 perlipc 似乎确实缺少这个
关于perl - perlipc 文档中的错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10456916/
我试图解开我在 perlipc 中看到的东西文档。 If you're writing to a pipe, you should also trap SIGPIPE. Otherwise, thin
我是一名优秀的程序员,十分优秀!