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() ignored for running process that never terminates #18894

Open
jarv opened this issue Sep 24, 2021 · 0 comments
Open

waitForExit() ignored for running process that never terminates #18894

jarv opened this issue Sep 24, 2021 · 0 comments

Comments

@jarv
Copy link

jarv commented Sep 24, 2021

On Linux, the timeout on waitForExit() is ignored in some cases.

Example

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

On MacOS the timeout is respected, on Linux the timeout is ignored while cat is blocked on reading input.

Interestingly this only happens when cat is invoked in a subshell,

let process = startProcess(command = "cat", args = args)

handles the timeout correct, as well as

let args = ["-c", "sleep 100"]
let process = startProcess(command = "/bin/sh", args = args)

Version

# nim -v
Nim Compiler Version 1.4.8 [Linux: amd64]
Compiled at 2021-05-25
Copyright (c) 2006-2021 by Andreas Rumpf

git hash: 44e653a9314e1b8503f0fa4a8a34c3380b26fff3
active boot switches: -d:release -d:danger
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant