7stud has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks
After fork()'ing, I am unable to catch a CHLD signal in the parent. In my example, the child process does nothing and calls die(). The parent would like to know that the CHLD process has terminated.
use strict; use warnings; use 5.010; my $pid = fork; if (!defined $pid) { die "Couldn't fork: $!"; } if ($pid) { #then in parent local $SIG{CHLD} = sub {say 'caught it';}; say 'hello world'; } else { #then in child die; } --output:-- hello world
My expected output:
caught it hello world #or hello world caught it
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: why can't I catch CHLD signal?
by GrandFather (Saint) on Mar 22, 2010 at 02:51 UTC | |
|
Re: why can't I catch CHLD signal?
by 7stud (Deacon) on Mar 22, 2010 at 03:03 UTC |