my $pid = fork( ); if ( defined $pid && $pid == 0 ) { # child system( $_[0]->arg ); if ($? == -1) { return "failed to execute: $!\n"; } elsif ($? & 127) { return "child died with signal %d, %s coredump\n", ($? & 127), ($? & 128) ? 'with' : 'without'; } else { return "child exited with value " . $? >> 8; } } else { # parent }