haskell / process

Library for dealing with system processes
http://hackage.haskell.org/package/process
Other
87 stars 82 forks source link

Use `O_DUPFD` instead of `dup` #284

Closed bgamari closed 1 year ago

bgamari commented 1 year ago

In #282 we introduced some rather subtle dup logic to ensure that the fork pipe fds don't shadow stdin/stdout/stderr. However, it turns out that POSIX provides a much simpler means of doing this: fcntl(fd, O_DUPFD) (manpage). We should rather use this.

expipiplus1 commented 1 year ago

or O_DUPFD_CLOEXEC for the CLOEXEC pipes, to avoid racing another process forking before setting CLOEXEC in a separate call

bgamari commented 1 year ago

Yes, fair point.