in reply to Re: Exit codes from forking children
in thread Exit codes from forking children

Good call.
defined( my $pid = open(CMD, '-|') ) or die("Can't fork: $!\n"); if ($pid == 0) { close(STDERR); open(STDERR, ">&STDOUT") or print "Unable to reopen STDOUT, errors may be lost: $!"; exec('/bin/tar', 'czf', '/nonexistent/test.tar.gz', '.') or die("Unable to exec: $!") } local $/ = undef; my $output .= <CMD>; close(CMD); if ($? == -1) { die("Can't close pipe: $!\n"); } elsif ($? & 127) { die("tar died from signal ", ($? & 127), "\n"); } elsif ($? >> 8) { die("tar exited with error ", ($? >> 8), "\n"); } print $output;
tar died from signal 13