[cs631apue] sish return code question

David Sevilla dsevilla at stevens.edu
Thu Dec 5 20:25:40 EST 2019


Hi Professor,

Context:
I wanted a quick clarification on a minor issue: the expected return code
in sish(1) after capturing SIGINT.

Question:
The manual page states that a "status of 127 should be returned if the
given command could not be executed for any reason." I interpreted "could
not be executed" as "could not begin executing".

However, if SIGINT is sent to an currently-executing child process of the
shell, should we still return 127, or mimic sh(1) behavior? This question
extends to expected behavior of entering ^C in interactive mode, while no
command is currently executing.

My Findings:
Apparently it's required by POSIX for the exit code for processes which
were terminated by a signal is greater than 128. It seems that most shells
use 128 + N in this case, where N is the number signal (thus when
terminated by SIGINT, the exit status is 130). Is it correct and expected
that I should handle termination by a signal as a special case?

Best,
David Sevilla.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.stevens.edu/pipermail/cs631apue/attachments/20191205/51198e21/attachment.html>


More information about the cs631apue mailing list