From e1fe79a9e705e3cab8f632cdbe8e1774cdef2761 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Thu, 19 Feb 2015 04:13:20 +0000 Subject: - exit code overhaul: forx, forbacktickx, loopwhilex, if, ifelse, ifte, ifthenelse - new -o option to forx, forbacktickx, loopwhilex - documentation updated - version: rc for 2.1.0.0 --- doc/exitcodes.html | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 doc/exitcodes.html (limited to 'doc/exitcodes.html') diff --git a/doc/exitcodes.html b/doc/exitcodes.html new file mode 100644 index 0000000..4b8afda --- /dev/null +++ b/doc/exitcodes.html @@ -0,0 +1,97 @@ + + + + + execline: exit codes + + + + + + +

+execline
+Software
+skarnet.org +

+ +

How to propagate exit codes up a process dynasty

+ +

+ Say we have a parent process P, child of a grandparent process +G, spawning a child process C and waiting for it. +Either C dies normally with an exit code from 0 to 255, or it is +killed by a signal. + How can we make sure that P reports to G what happened +to C, with as much precision as possible ? +

+ +

+ The problem is, there's more information in a wstat (the +structure filled in by +waitpid()) +than a process can report by +simply exiting. P could exit with the same exit code as C, +but then what should it do if C has been killed by a signal ? +

+ +

+ An idea is to have P kill itself with the same signal that killed +C. +But that's actually not right, because P itself could be killed by a +signal from another source, and G needs that information. "P has been +killed by a signal" and "C has been killed by a signal" are two +different informations, so they should not be reported in the same way. +

+ +

+ So, any way you look at it, there is always more information than we +can report. +

+ +

+Shells have their own +convention +for reporting crashes, but since any exit code greater than 127 is reported +as is, the information given by the shell is unreliable: "child exited 129" +and "child was killed by SIGHUP" are indistinguishable. When shells get +nested, all bets are off - the information conveyed by exit codes becomes +devoid of meaning pretty fast. We need something better. +

+ +

execline's solution

+ +

+execline commands such as forx, that can report +a child's exit code, proceed that way when they're in the position of +P: +

+ + + +

+ Rationale: +

+ + + + + -- cgit v1.2.3