The strace utility shows that, with child.pl's print omitted, main.pl is stuck in the wait4() system call, waiting for child.pl to exit and emit SIGCHLD. It seems that child.pl is not receiving SIGPIPE under those circumstances (proof below). Perhaps child.pl does not set up its end of the pipe, having nothing to say.
With the print statement in, strace shows that child.pl exits with SIGPIPE, just the way we expect.
Changing child.pl to,
does not change the behavior, so SIGPIPE is not received by child.pl. Restoring the print line yields the message,#!/usr/bin/perl $SIG{PIPE} = sub { die 'SIGPIPE received' }; $| = 1; sleep 10; # print "x\n"; while (1) { sleep 10; }
$ ./main.pl SIGPIPE received at ./child.pl line 2. $
As ysth suggests, you could kill the child explicitly with SIGINT.
After Compline,
Zaxo
In reply to Re: How to end a process started with open "cmd |" before it has output
by Zaxo
in thread How to end a process started with open "cmd |" before it has output
by Crackers2
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |