From 601b262a8dc98b36f06585bd432396af85981a99 Mon Sep 17 00:00:00 2001 From: modk Date: Mon, 26 Jan 2015 00:06:43 +0100 Subject: [PATCH 1/3] Fixes parallel build on FreeBSD --- lib/posix/posix.nim | 16 ++++++++-------- lib/pure/osproc.nim | 5 ++++- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/posix/posix.nim b/lib/posix/posix.nim index d56adf7f50773..fbd07ca25eca6 100644 --- a/lib/posix/posix.nim +++ b/lib/posix/posix.nim @@ -1405,14 +1405,6 @@ var ## Report status of stopped child process. WEXITSTATUS* {.importc, header: "".}: cint ## Return exit status. - WIFCONTINUED* {.importc, header: "".}: cint - ## True if child has been continued. - WIFEXITED* {.importc, header: "".}: cint - ## True if child exited normally. - WIFSIGNALED* {.importc, header: "".}: cint - ## True if child exited due to uncaught signal. - WIFSTOPPED* {.importc, header: "".}: cint - ## True if child is currently stopped. WSTOPSIG* {.importc, header: "".}: cint ## Return signal number that caused process to stop. WTERMSIG* {.importc, header: "".}: cint @@ -1559,6 +1551,14 @@ var MSG_OOB* {.importc, header: "".}: cint ## Out-of-band data. +proc WIFCONTINUED*(s:cint) : bool {.importc, header: "".} + ## True if child has been continued. +proc WIFEXITED*(s:cint) : bool {.importc, header: "".} + ## True if child exited normally. +proc WIFSIGNALED*(s:cint) : bool {.importc, header: "".} + ## True if child exited due to uncaught signal. +proc WIFSTOPPED*(s:cint) : bool {.importc, header: "".} + ## True if child is currently stopped. when defined(linux): var diff --git a/lib/pure/osproc.nim b/lib/pure/osproc.nim index 20a0c401ed488..cc2dfc4cda7d4 100644 --- a/lib/pure/osproc.nim +++ b/lib/pure/osproc.nim @@ -848,7 +848,10 @@ elif not defined(useNimRtl): if kill(p.id, SIGCONT) != 0'i32: raiseOsError(osLastError()) proc running(p: Process): bool = - var ret = waitpid(p.id, p.exitCode, WNOHANG) + var status : cint + var ret = waitpid(p.id, status, WNOHANG) + if WIFEXITED(status): + p.exitCode = status if ret == 0: return true # Can't establish status. Assume running. result = ret == int(p.id) From e37e9978689c0ae394a8fa1cd748d969f079f1a4 Mon Sep 17 00:00:00 2001 From: modk Date: Tue, 27 Jan 2015 22:39:24 +0100 Subject: [PATCH 2/3] Set status to something else than 0 --- lib/pure/osproc.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pure/osproc.nim b/lib/pure/osproc.nim index cc2dfc4cda7d4..7261dcf5628fa 100644 --- a/lib/pure/osproc.nim +++ b/lib/pure/osproc.nim @@ -848,7 +848,7 @@ elif not defined(useNimRtl): if kill(p.id, SIGCONT) != 0'i32: raiseOsError(osLastError()) proc running(p: Process): bool = - var status : cint + var status : cint = 1 var ret = waitpid(p.id, status, WNOHANG) if WIFEXITED(status): p.exitCode = status From 458e3b2f07eea9a1f6d369cb10e7504f4e4d3855 Mon Sep 17 00:00:00 2001 From: modk Date: Thu, 29 Jan 2015 12:51:22 +0100 Subject: [PATCH 3/3] FreeBSD-specific code --- lib/pure/osproc.nim | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/pure/osproc.nim b/lib/pure/osproc.nim index 7261dcf5628fa..6361dfb0923ba 100644 --- a/lib/pure/osproc.nim +++ b/lib/pure/osproc.nim @@ -848,10 +848,14 @@ elif not defined(useNimRtl): if kill(p.id, SIGCONT) != 0'i32: raiseOsError(osLastError()) proc running(p: Process): bool = - var status : cint = 1 - var ret = waitpid(p.id, status, WNOHANG) - if WIFEXITED(status): - p.exitCode = status + var ret : int + when not defined(freebsd): + ret = waitpid(p.id, p.exitCode, WNOHANG) + else: + var status : cint = 1 + ret = waitpid(p.id, status, WNOHANG) + if WIFEXITED(status): + p.exitCode = status if ret == 0: return true # Can't establish status. Assume running. result = ret == int(p.id)