Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

waitForExit() with timeout hangs on already dead processes on Linux #5091

Closed
jfhg opened this issue Dec 4, 2016 · 0 comments · Fixed by #23743
Closed

waitForExit() with timeout hangs on already dead processes on Linux #5091

jfhg opened this issue Dec 4, 2016 · 0 comments · Fixed by #23743

Comments

@jfhg
Copy link
Contributor

jfhg commented Dec 4, 2016

On Linux calling waitForExit() with timeout on a process that already exited will hang until the timeout expires.
The following program shows the issue:

import osproc, os, times

const filename = when defined(Windows): "tafalse.exe" else: "tafalse"
let dir = getCurrentDir() / "tests" / "osproc"
doAssert fileExists(dir / filename)

var p = startProcess(filename, dir)
doAssert(waitForExit(p) == QuitFailure)

p = startProcess(filename, dir)
os.sleep(1000) # make sure process has exited already

let atStart = getTime()
const msWait = 2000

try:
  discard waitForExit(p, msWait)
except OSError:
  echo "OSException"

# check that we don't have to wait msWait milliseconds
doAssert(getTime() <  atStart + milliseconds(msWait))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants