diff options
Diffstat (limited to 'lib/posix')
-rw-r--r-- | lib/posix/posix.nim | 9 | ||||
-rw-r--r-- | lib/posix/posix_linux_amd64.nim | 9 | ||||
-rw-r--r-- | lib/posix/posix_other.nim | 15 |
3 files changed, 24 insertions, 9 deletions
diff --git a/lib/posix/posix.nim b/lib/posix/posix.nim index ab608efc6..02312a4d5 100644 --- a/lib/posix/posix.nim +++ b/lib/posix/posix.nim @@ -97,15 +97,6 @@ when not defined(macosx): ## Second-granularity time of last status change. result = s.st_ctim.tv_sec -proc WIFCONTINUED*(s:cint) : bool {.importc, header: "<sys/wait.h>".} - ## True if child has been continued. -proc WIFEXITED*(s:cint) : bool {.importc, header: "<sys/wait.h>".} - ## True if child exited normally. -proc WIFSIGNALED*(s:cint) : bool {.importc, header: "<sys/wait.h>".} - ## True if child exited due to uncaught signal. -proc WIFSTOPPED*(s:cint) : bool {.importc, header: "<sys/wait.h>".} - ## True if child is currently stopped. - when hasAioH: proc aio_cancel*(a1: cint, a2: ptr Taiocb): cint {.importc, header: "<aio.h>".} proc aio_error*(a1: ptr Taiocb): cint {.importc, header: "<aio.h>".} 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 diff --git a/lib/posix/posix_other.nim b/lib/posix/posix_other.nim index 6e1c33605..b1cc244b7 100644 --- a/lib/posix/posix_other.nim +++ b/lib/posix/posix_other.nim @@ -611,3 +611,18 @@ when hasSpawnH: # OR'ing of flags: const POSIX_SPAWN_USEVFORK* = cint(0) +# <sys/wait.h> +proc WEXITSTATUS*(s: cint): cint {.importc, header: "<sys/wait.h>".} + ## Exit code, iff WIFEXITED(s) +proc WTERMSIG*(s: cint): cint {.importc, header: "<sys/wait.h>".} + ## Termination signal, iff WIFSIGNALED(s) +proc WSTOPSIG*(s: cint): cint {.importc, header: "<sys/wait.h>".} + ## Stop signal, iff WIFSTOPPED(s) +proc WIFEXITED*(s: cint): bool {.importc, header: "<sys/wait.h>".} + ## True if child exited normally. +proc WIFSIGNALED*(s: cint): bool {.importc, header: "<sys/wait.h>".} + ## True if child exited due to uncaught signal. +proc WIFSTOPPED*(s: cint): bool {.importc, header: "<sys/wait.h>".} + ## True if child is currently stopped. +proc WIFCONTINUED*(s: cint): bool {.importc, header: "<sys/wait.h>".} + ## True if child has been continued. |