[GHC] #7229: Detecting if a process was killed by a signal is impossible
GHC
ghc-devs at haskell.org
Sat Nov 9 11:11:16 UTC 2013
#7229: Detecting if a process was killed by a signal is impossible
--------------------------------------+------------------------------------
Reporter: benmachine | Owner:
Type: bug | Status: new
Priority: high | Milestone: 7.8.1
Component: libraries/process | Version:
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture: Unknown/Multiple
Type of failure: None/Unknown | Difficulty: Unknown
Test Case: | Blocked By:
Blocking: | Related Tickets:
--------------------------------------+------------------------------------
Comment (by andersk):
Wikipedia is confused. If you go actually read the
[http://pubs.opengroup.org/onlinepubs/9699919799/functions/wait.html
specification], you see
> WEXITSTATUS(stat_val): … this macro evaluates to the low-order 8 bits of
the status argument that the child process passed to _exit() or exit(), or
the value the child process returned from main().
and also
> The status values are retrieved by macros, rather than given as specific
bit encodings as they are in most historical implementations (and thus
expected by existing programs). This was necessary to eliminate a
limitation on the number of signals an implementation can support that was
inherent in the traditional encodings.
Here’s the
[https://sourceware.org/git/?p=glibc.git;a=blob;f=bits/waitstatus.h;hb=refs/tags/glibc-2.18#l27
definition] from glibc:
{{{
/* If WIFEXITED(STATUS), the low-order 8 bits of the status. */
#define __WEXITSTATUS(status) (((status) & 0xff00) >> 8)
/* If WIFSIGNALED(STATUS), the terminating signal. */
#define __WTERMSIG(status) ((status) & 0x7f)
}}}
which is to say that bits 8-15 of the wait()/waitpid() status are bits 0-7
of the exit() status (the rest of the exit() status being thrown away),
and bits 0-6 of the wait()/waitpid() status are the signal number. This
agrees with the Perl/Python encoding (because, of course, that’s where the
Perl/Python encoding came from).
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/7229#comment:17>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list