WIFSIGNALED means process has exited too (with a bang!) (#5678)

This commit is contained in:
Jacek Sieka 2017-04-28 03:39:32 +08:00 • committed by Andreas Rumpf
commit 0055729755
6 changed files with 95 additions and 18 deletions

View file

@ -602,3 +602,12 @@ var
include posix_linux_amd64_consts
const POSIX_SPAWN_USEVFORK* = cint(0x40) # needs _GNU_SOURCE!
# <sys/wait.h>
proc WEXITSTATUS*(s: cint): cint = (s and 0xff00) shr 8
proc WTERMSIG*(s:cint): cint = s and 0x7f
proc WSTOPSIG*(s:cint): cint = WEXITSTATUS(s)
proc WIFEXITED*(s:cint) : bool = WTERMSIG(s) == 0
proc WIFSIGNALED*(s:cint) : bool = (cast[int8]((s and 0x7f) + 1) shr 1) > 0
proc WIFSTOPPED*(s:cint) : bool = (s and 0xff) == 0x7f
proc WIFCONTINUED*(s:cint) : bool = s == W_CONTINUED