twaitforexit.nim 538 B

123456789101112131415161718
  1. import std/[osproc, os, times]
  2. block: # bug #5091
  3. when defined(linux):
  4. const filename = "false"
  5. var p = startProcess(filename, options = {poStdErrToStdOut, poUsePath})
  6. os.sleep(1000) # make sure process has exited already
  7. let atStart = getTime()
  8. const msWait = 2000
  9. try:
  10. discard waitForExit(p, msWait)
  11. except OSError:
  12. discard
  13. # check that we don't have to wait msWait milliseconds
  14. doAssert(getTime() < atStart + milliseconds(msWait))