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 #### caught it hello world #or hello world caught it