Skip to content

Commit

Permalink
Merge pull request nim-lang#2010 from modk/freebsd-parallel-build
Browse files Browse the repository at this point in the history
Fix parallel build on FreeBSD
  • Loading branch information
Araq committed Feb 1, 2015
2 parents fa166dc + 458e3b2 commit 3b45ac4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
16 changes: 8 additions & 8 deletions lib/posix/posix.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1405,14 +1405,6 @@ var
## Report status of stopped child process.
WEXITSTATUS* {.importc, header: "<sys/wait.h>".}: cint
## Return exit status.
WIFCONTINUED* {.importc, header: "<sys/wait.h>".}: cint
## True if child has been continued.
WIFEXITED* {.importc, header: "<sys/wait.h>".}: cint
## True if child exited normally.
WIFSIGNALED* {.importc, header: "<sys/wait.h>".}: cint
## True if child exited due to uncaught signal.
WIFSTOPPED* {.importc, header: "<sys/wait.h>".}: cint
## True if child is currently stopped.
WSTOPSIG* {.importc, header: "<sys/wait.h>".}: cint
## Return signal number that caused process to stop.
WTERMSIG* {.importc, header: "<sys/wait.h>".}: cint
Expand Down Expand Up @@ -1559,6 +1551,14 @@ var
MSG_OOB* {.importc, header: "<sys/socket.h>".}: cint
## Out-of-band data.

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 defined(linux):
var
Expand Down
9 changes: 8 additions & 1 deletion lib/pure/osproc.nim
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,14 @@ 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 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)

Expand Down

0 comments on commit 3b45ac4

Please sign in to comment.