+waitpid status printer.
authorjkratoch <>
Thu, 14 Oct 2010 13:25:11 +0000 (13:25 +0000)
committerjkratoch <>
Thu, 14 Oct 2010 13:25:11 +0000 (13:25 +0000)
bin/whyexit [new file with mode: 0755]

diff --git a/bin/whyexit b/bin/whyexit
new file mode 100755 (executable)
index 0000000..af5a452
--- /dev/null
@@ -0,0 +1,16 @@
+#! /usr/bin/perl
+use strict;
+use warnings;
+use POSIX;
+BEGIN { eval 'use Glib;1;' or eval 'sub Glib::strsignal { return "?"; }'; }
+
+sub WCOREDUMP($) { return $_[0] & 0x80; }
+sub WIFCONTINUED($) { return $_[0]==0xffff; }
+
+my $r=system @ARGV;
+$r==$? or die;
+die "WEXITSTATUS ".WEXITSTATUS($r)."\n" if WIFEXITED $r;
+die "WTERMSIG ".WTERMSIG($r)."=".Glib::strsignal(WTERMSIG($r))." WCOREDUMP=".(WCOREDUMP($r) ? "yes" : "no")."\n" if WIFSIGNALED $r;
+die "WSTOPSIG ".WSTOPSIG($r)."=".Glib::strsignal(WSTOPSIG($r))."\n" if WIFSTOPPED $r;
+die "WIFCONTINUED\n" if WIFCONTINUED $r;
+die "? $r\n";