summary refs log tree commit diff stats
path: root/lib/posix/posix_linux_amd64.nim
diff options
context:
space:
mode:
authorJacek Sieka <arnetheduck@gmail.com>2017-04-28 03:39:32 +0800
committerAndreas Rumpf <rumpf_a@web.de>2017-04-27 21:39:32 +0200
commit0055729755a14020e670d2f564b2f20253ccd28f (patch)
treee755955368328e08a086552446d9f85d4d6e904e /lib/posix/posix_linux_amd64.nim
parent40f79e6cddf63b05843284263dc36013da2ee1b7 (diff)
downloadNim-0055729755a14020e670d2f564b2f20253ccd28f.tar.gz
WIFSIGNALED means process has exited too (with a bang!) (#5678)
Diffstat (limited to 'lib/posix/posix_linux_amd64.nim')
-rw-r--r--lib/posix/posix_linux_amd64.nim9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/posix/posix_linux_amd64.nim b/lib/posix/posix_linux_amd64.nim
index 4948642c1..70f7e710f 100644
--- a/lib/posix/posix_linux_amd64.nim
+++ b/lib/posix/posix_linux_amd64.nim
@@ -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