Using waitForExit I see different behavior in the stdlib when a process is blocked on IO
Example that doesn't timeout:
import osproc
import streams
let args = ["-c", "cat"]
let process = startProcess(command = "/bin/sh", args = args)
let ret = waitForExit(p = process, timeout = 1000)
let strm = process.outputStream()
echo strm.readAll()
echo ret
https://play.nim-lang.org/#ix=3zQo
While this times out as expected:
import osproc
import streams
let args = ["-c", "sleep 5"]
let process = startProcess(command = "/bin/sh", args = args)
let ret = waitForExit(p = process, timeout = 1000)
let strm = process.outputStream()
echo strm.readAll()
echo ret
For my application, I passing user provided strings into startProcess and would like to detect a timeout if possible.
Note I also opened https://github.com/nim-lang/Nim/issues/18894 but thought that maybe I would get some ideas on whether this is a bug by posting here.