Util.pm/CLIUtil.pm: clean up abnormal exit code handling
commitaaeae21a54bd4d288b91821c5f3d9234d090ebd5
authorKyle J. McKay <mackyle@gmail.com>
Sun, 27 Jun 2021 23:13:30 +0000 (27 16:13 -0700)
committerKyle J. McKay <mackyle@gmail.com>
Sun, 27 Jun 2021 23:13:30 +0000 (27 16:13 -0700)
treefbc3fc1ae46acb2bce895d4324ddf3e4529ec540
parent4ab2d17b2b1cb936f99fdb9fd640b00f99cca4a9
Util.pm/CLIUtil.pm: clean up abnormal exit code handling

When the setup_pager function arranges for STDOUT to be paged,
it was causing the exit code of the process (when using the
special "become child" feature) to be that of the pager rather
than the program itself.  Fix this to capture the exit status
of the real program and then exit with that value instead.

When the noFatalsToBrowser function disables the CGI redirection
of die from the unreadable-when-dumped-on-the-terminal output
to something more legible, it inspects the various error variables
to determine what exit code it should use (if it's not in an
eval block).

In both of these cases, be careful to make sure that the exit
code used is in the range 0..255 inclusive and furthermore, that
if the exit was caused by a signal that it's the 128+signal_num
value rather than the bare signal_num value.

Force unexpected exit codes outside the 0.255 range to be 255.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
Girocco/CLIUtil.pm
Girocco/Util.pm