mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-04 12:07:51 +00:00
Fixes #5091.
Ensure we don't wait on an exited process on Linux
(cherry picked from commit 288d5c4ac3)
This commit is contained in:
@@ -1416,6 +1416,8 @@ elif not defined(useNimRtl):
|
||||
tmspec.tv_nsec = (timeout * 1_000_000)
|
||||
|
||||
try:
|
||||
if not running(p):
|
||||
return exitStatusLikeShell(p.exitStatus)
|
||||
if clock_gettime(CLOCK_REALTIME, stspec) == -1:
|
||||
raiseOSError(osLastError())
|
||||
while true:
|
||||
|
||||
18
tests/osproc/twaitforexit.nim
Normal file
18
tests/osproc/twaitforexit.nim
Normal file
@@ -0,0 +1,18 @@
|
||||
import std/[osproc, os, times]
|
||||
|
||||
block: # bug #5091
|
||||
when defined(linux):
|
||||
const filename = "false"
|
||||
var p = startProcess(filename, options = {poStdErrToStdOut, poUsePath})
|
||||
os.sleep(1000) # make sure process has exited already
|
||||
|
||||
let atStart = getTime()
|
||||
const msWait = 2000
|
||||
|
||||
try:
|
||||
discard waitForExit(p, msWait)
|
||||
except OSError:
|
||||
discard
|
||||
|
||||
# check that we don't have to wait msWait milliseconds
|
||||
doAssert(getTime() < atStart + milliseconds(msWait))
|
||||
Reference in New Issue
Block a user