mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-06 13:07:48 +00:00
make sure first call to running() after process exit returns false
This commit is contained in:
@@ -965,10 +965,16 @@ elif not defined(useNimRtl):
|
||||
var ret : int
|
||||
var status : cint = 1
|
||||
ret = waitpid(p.id, status, WNOHANG)
|
||||
if ret == int(p.id) and WIFEXITED(status):
|
||||
p.exitStatus = status
|
||||
if ret == 0: return true # Can't establish status. Assume running.
|
||||
result = ret == int(p.id)
|
||||
if ret == int(p.id):
|
||||
if WIFEXITED(status):
|
||||
p.exitStatus = status
|
||||
return false
|
||||
else:
|
||||
return true
|
||||
elif ret == 0:
|
||||
return true # Can't establish status. Assume running.
|
||||
else:
|
||||
return false
|
||||
|
||||
proc terminate(p: Process) =
|
||||
if kill(p.id, SIGTERM) != 0'i32:
|
||||
|
||||
@@ -16,3 +16,8 @@ var running = true
|
||||
while running:
|
||||
running = running(p)
|
||||
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))
|
||||
|
||||
Reference in New Issue
Block a user