From: epg <> Date: Sat, 30 Oct 2004 17:25:01 +0000 (+0000) Subject: Make handling of child process death consistent. X-Git-Url: https://diplodocus.org/git/flac-archive/commitdiff_plain/c069d00b1502aa08be2bdf0a197ab1110ba350d5?ds=inline Make handling of child process death consistent. --- diff --git a/fa-flacd b/fa-flacd index 2c6e103..3e9e7cb 100755 --- a/fa-flacd +++ b/fa-flacd @@ -90,12 +90,16 @@ sub flac { 'cue', '--no-padding', '--best', map({ ('-T', $_) } @tags), 'wav'); - if (WIFEXITED($status) and ($status = WEXITSTATUS($status)) != 0) { - die("flac: $status"); + if (WIFEXITED($status)) { + if (($status = WEXITSTATUS($status)) != 0) { + die("flac exited with status $status"); + } } elsif (WIFSIGNALED($status)) { die("flac killed with signal ", WTERMSIG($status)); } elsif (WIFSTOPPED($status)) { die("flac stopped with signal ", WSTOPSIG($status)); + } else { + die("Major horkage on system(flac): \$? = $? \$! = $!"); } verbose("Cleaning up $dir\n"); @@ -150,11 +154,11 @@ sub deljob { verbose("$pid finished ("); if (WIFEXITED($status)) { - verbose('exited ', WEXITSTATUS($status)); + verbose('exited with status ', WEXITSTATUS($status)); } elsif (WIFSIGNALED($status)) { - verbose('signalled ', WTERMSIG($status)); + verbose('killed with signal ', WTERMSIG($status)); } elsif (WIFSTOPPED($status)) { - verbose('stopped ', WSTOPSIG($status)); + verbose('stopped with signal ', WSTOPSIG($status)); } verbose(")\n"); diff --git a/fa-rip b/fa-rip index 5e91afa..1a9bc2a 100755 --- a/fa-rip +++ b/fa-rip @@ -31,22 +31,16 @@ sub run_or_die { my $command = shift; my $status; - system($command); + $status = system($command); - if (WIFEXITED($?)) { - $status = WEXITSTATUS($?); - if ($status != 0) { - die("$command exited $status"); + if (WIFEXITED($status)) { + if (($status = WEXITSTATUS($status)) != 0) { + die("$command exited with status $status"); } - - } elsif (WIFSIGNALED($?)) { - $status = WTERMSIG($?); - die("$command signalled $status"); - - } elsif (WIFSTOPPED($?)) { - $status = WSTOPSIG($?); - die("$command stopped $status"); - + } elsif (WIFSIGNALED($status)) { + die("$command killed with signal ", WTERMSIG($status)); + } elsif (WIFSTOPPED($status)) { + die("$command stopped with signal ", WSTOPSIG($status)); } else { die("Major horkage on system($command): \$? = $? \$! = $!"); }