Discussion:
Exit codes
(too old to reply)
Paul Mazzucco
2005-03-05 23:10:57 UTC
Permalink
If the exitCodes are enabled within the shell, what value are we to
print if the command included an '&'? Or, are we not to print any exit
code in the case of an amperstand?
Joe Barrett
2005-03-06 05:38:49 UTC
Permalink
Post by Paul Mazzucco
If the exitCodes are enabled within the shell, what value are we to
print if the command included an '&'? Or, are we not to print any exit
code in the case of an amperstand?
The only time the shell would know how to report an exit code is if it
waits for the process to exit (unless the shell implements job control
[which this shell does not]). If the shell is running as a background
process, it shouldn't report an exit code for the process, because it
won't have any way of knowing when/if it exists.

Joe
Iulian Neamtiu
2005-03-07 20:57:08 UTC
Permalink
Post by Joe Barrett
Post by Paul Mazzucco
If the exitCodes are enabled within the shell, what value are we to
print if the command included an '&'? Or, are we not to print any
exit code in the case of an amperstand?
The only time the shell would know how to report an exit code is if it
waits for the process to exit (unless the shell implements job control
[which this shell does not]). If the shell is running as a background
process, it shouldn't report an exit code for the process, because it
won't have any way of knowing when/if it exists.
That's correct, so feel free to ignore the
if (exitCodes)
test if the process is spawned in background. The Unix shell can do this
because the wait() system call in Unix supports wildcard waiting, i.e.
wait for *any child* to finish, not for one with a specific PID.

The GeekOS Wait() syscall is not that powerful.

Type 'man 2 wait' if you want to find out more.

Iulian

Continue reading on narkive:
Loading...