Bug 16686 – Can not spawn subprocess and read from File at same time

Status
ASSIGNED
Severity
normal
Priority
P3
Component
phobos
Product
D
Version
D2
Platform
x86
OS
Mac OS X
Creation time
2016-11-15T01:09:45Z
Last change time
2024-12-01T16:28:16Z
Assigned to
Alexandru Razvan Caciulescu
Creator
André Puel
Moved to GitHub: phobos#9695 →

Attachments

IDFilenameSummaryContent-TypeSize
1622oi2.dScript that reproduces the problemtext/plain274

Comments

Comment #0 by andrepuel — 2016-11-15T01:09:45Z
Created attachment 1622 Script that reproduces the problem In OSX, the implementation of the C function read() as well as the C function fileno() will invoke flockfile on the given argument. The function `spawnProcessImpl` from the `std.process` module tries to extract the fileno from the three File that are passed (stdin, stdout and stderr), if one of this files is busy doing read() in another thread, then the subprocess will not be launched until the read() is fulfilled and the file is unlocked. Attached is a simple code that demonstrates the issue. A read in stdin is done in the main thread, while a secondary thread tries to execute a ls. Due to the bug, the ls result will be available only after the user inputs a line in the stdin.
Comment #1 by bugzilla — 2020-01-05T16:09:38Z
Just for reference: On linux (debian) this works.
Comment #2 by robert.schadek — 2024-12-01T16:28:16Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/9695 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB