+sub failedcmd {
+ my $errnoval = $!;
+ printcmd \*STDERR, "$_[0]: failed command:", @_;
+ if ($errnoval) {
+ fail "failed to fork/exec: $!";
+ } elsif (!($? & 0xff)) {
+ fail "subprocess failed with error exit status ".($?>>8);
+ } elsif ($?) {
+ fail "subprocess crashed (wait status $?)";
+ } else {
+ fail "subprocess produced invalid output";
+ }
+}
+