make sure first call to running() after process exit returns false
This commit is contained in:
parent
b453a8e616
commit
95188edf6f
2 changed files with 15 additions and 4 deletions
|
|
@ -965,10 +965,16 @@ elif not defined(useNimRtl):
|
||||||
var ret : int
|
var ret : int
|
||||||
var status : cint = 1
|
var status : cint = 1
|
||||||
ret = waitpid(p.id, status, WNOHANG)
|
ret = waitpid(p.id, status, WNOHANG)
|
||||||
if ret == int(p.id) and WIFEXITED(status):
|
if ret == int(p.id):
|
||||||
p.exitStatus = status
|
if WIFEXITED(status):
|
||||||
if ret == 0: return true # Can't establish status. Assume running.
|
p.exitStatus = status
|
||||||
result = ret == int(p.id)
|
return false
|
||||||
|
else:
|
||||||
|
return true
|
||||||
|
elif ret == 0:
|
||||||
|
return true # Can't establish status. Assume running.
|
||||||
|
else:
|
||||||
|
return false
|
||||||
|
|
||||||
proc terminate(p: Process) =
|
proc terminate(p: Process) =
|
||||||
if kill(p.id, SIGTERM) != 0'i32:
|
if kill(p.id, SIGTERM) != 0'i32:
|
||||||
|
|
|
||||||
|
|
@ -16,3 +16,8 @@ var running = true
|
||||||
while running:
|
while running:
|
||||||
running = running(p)
|
running = running(p)
|
||||||
doAssert(waitForExit(p) == QuitFailure)
|
doAssert(waitForExit(p) == QuitFailure)
|
||||||
|
|
||||||
|
# make sure that first call to running() after process exit returns false
|
||||||
|
p = startProcess(filename, dir)
|
||||||
|
os.sleep(500)
|
||||||
|
doAssert(not running(p))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue