[Haskell-cafe] Strange exit status behavior from the process package

Brandon Allbery allbery.b at gmail.com
Sun Sep 22 06:24:06 CEST 2013


On Sat, Sep 21, 2013 at 11:12 PM, Michael Xavier
<michael at michaelxavier.net>wrote:

> I've run into some strangeness with the process package. When you kill
> some processes on the command line you correctly get a non-zero exit
> status. However when using the process package's terminateProcess (which
> sends a SIGTERM), it returns an ExitSuccess:
>

The 143 you get from the shell is synthetic (and nonportable). Signals are
not normal exit codes; WEXITSTATUS is not defined in this case (but often
will be 0, as seems to be shown here), instead WTERMSIG will be set to the
signal that terminated the process. The caller should be using WIFEXITED /
WIFSIGNALED / WIFSTOPPED to determine the cause of the termination and then
the appropriate WEXITSTATUS / WTERMSIG / WSTOPSIG call to determine the
value.

It sounds like the createProcess API does not recognize signal exit at all,
and uses WEXITSTATUS even when it is not valid.

-- 
brandon s allbery kf8nh                               sine nomine associates
allbery.b at gmail.com                                  ballbery at sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130922/ee48d557/attachment.htm>


More information about the Haskell-Cafe mailing list