Skip to content

Use O_DUPFD instead of dup #284

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

Closed
bgamari opened this issue Mar 30, 2023 · 2 comments
Closed

Use O_DUPFD instead of dup #284

bgamari opened this issue Mar 30, 2023 · 2 comments

Comments

@bgamari
Copy link
Contributor

bgamari commented Mar 30, 2023

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
Copy link

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

@bgamari
Copy link
Contributor Author

bgamari commented Mar 31, 2023

Yes, fair point.

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

2 participants