开发者

What does SIGPIPE in this situation mean?

I have the following script structure: script A opens PIPE on B, and B opens PIPE on C. So the dataflow is A->B->C. B catches 开发者_开发问答SIGPIPE. Though descriptors IN and OUT are opened:

$SIG{'PIPE'} = sub {
$logger->info('caught PIPE signal.');
$logger->info("STDIN status: ".STDIN->opened());
$logger->info("STDOUT status: ".OUT->opened());
die;
};

STDIN status: 1
STDOUT status: 1

I have added IN to the $pool IO::Select and when IN is in the $pool->can_read(), I read from it with sysread(). Once a second I write to OUT with print. Also I have a listen socket in the $pool and clients can connect to it. But I only read from clients. I'm writing to OUT only.


According to the Wikipedia article, it means that C has died:

On POSIX-compliant platforms, SIGPIPE is the signal sent to a process when it attempts to write to a pipe without a process connected to the other end.


The descriptors will be open even after the process has died. You could, for example, still read things that the program wrote before it died.

However, if you try to write to the dead program, it will throw a SIGPIPE at you.

You can check if a child process is dead by waiting on its PID:

waitpid($childpid, &WNOHANG);

If this returns 0, the child is still running.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜