Bug 13100 – std.process.setCLOEXEC() throws on invalid file descriptor

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
Linux
Creation time
2014-07-11T18:51:00Z
Last change time
2014-07-12T00:10:43Z
Assigned to
nobody
Creator
bugzilla

Comments

Comment #0 by bugzilla — 2014-07-11T18:51:30Z
This is based on a report I received by e-mail from a D user. If a program that calls spawnProcess() is run in an environment where one or more of the standard streams are closed, the setCLOEXEC() function will throw an exception and the child process will terminate. I will send a pull request that fixes this shortly.
Comment #1 by bugzilla — 2014-07-11T19:20:36Z
Comment #2 by github-bugzilla — 2014-07-12T00:10:43Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/b7af42bafa7f4cdae415daf0d1e5bb212a40bd88 Fix issue #13100 - std.process.setCLOEXEC() throws There are two cases in which the fcntl() calls may fail: 1) the file descriptor is invalid, in which case errno == EBADF, 2) they receive invalid arguments, in which case errno == EINVAL. We just want to ignore the error in the former case, as evidenced by the bug report, and the latter means that we have an error in std.process, which is best handled by an assertion. (Note that it was never possible to catch the exception anyway, since it was thrown in the child process.) https://github.com/D-Programming-Language/phobos/commit/357b627d2b7349c5fae8fc336f988242cd9fd51f Merge pull request #2326 from kyllingstad/no-setcloexec-fail Fix issue #13100 - std.process.setCLOEXEC() throws on invalid file descriptor