another attempt at properly declaring the status variable

This commit is contained in:
Johannes Hofmann 2016-09-25 10:16:14 +02:00
commit 1dccbaf9a0

View file

@ -1039,7 +1039,6 @@ elif not defined(useNimRtl):
template adjustTimeout(t, s, e: Timespec) = template adjustTimeout(t, s, e: Timespec) =
var diff: int var diff: int
var b: Timespec var b: Timespec
var status : cint = 1
b.tv_sec = e.tv_sec b.tv_sec = e.tv_sec
b.tv_nsec = e.tv_nsec b.tv_nsec = e.tv_nsec
e.tv_sec = (e.tv_sec - s.tv_sec).Time e.tv_sec = (e.tv_sec - s.tv_sec).Time
@ -1067,6 +1066,7 @@ elif not defined(useNimRtl):
# initialized with -3, wrong success exit codes are prevented. # initialized with -3, wrong success exit codes are prevented.
if p.exitStatus != -3: return p.exitStatus if p.exitStatus != -3: return p.exitStatus
if timeout == -1: if timeout == -1:
var status : cint = 1
if waitpid(p.id, status, 0) < 0: if waitpid(p.id, status, 0) < 0:
raiseOSError(osLastError()) raiseOSError(osLastError())
p.exitStatus = status p.exitStatus = status
@ -1100,6 +1100,7 @@ elif not defined(useNimRtl):
let res = sigtimedwait(nmask, sinfo, tmspec) let res = sigtimedwait(nmask, sinfo, tmspec)
if res == SIGCHLD: if res == SIGCHLD:
if sinfo.si_pid == p.id: if sinfo.si_pid == p.id:
var status : cint = 1
if waitpid(p.id, status, 0) < 0: if waitpid(p.id, status, 0) < 0:
raiseOSError(osLastError()) raiseOSError(osLastError())
p.exitStatus = status p.exitStatus = status
@ -1122,6 +1123,7 @@ elif not defined(useNimRtl):
# timeout expired, so we trying to kill process # timeout expired, so we trying to kill process
if posix.kill(p.id, SIGKILL) == -1: if posix.kill(p.id, SIGKILL) == -1:
raiseOSError(osLastError()) raiseOSError(osLastError())
var status : cint = 1
if waitpid(p.id, status, 0) < 0: if waitpid(p.id, status, 0) < 0:
raiseOSError(osLastError()) raiseOSError(osLastError())
p.exitStatus = status p.exitStatus = status