`std::process`: Close all file descriptors not explicitly passed
Nobody has claimed this yet.
- Dominant language
- Markdown
- Stars
- 6.6k
- Forks
- 1.7k
- Avg merge
- 16h 14m
- Merged PRs (30d)
- 1
Description
There are libraries, such as wlroots and GLib, that do not atomically set O_CLOEXEC on the file descriptors they create. Instead, they require any program using the library to close every file descriptor between fork() and exec(), except for an allowlist that should be passed to the child process.
GLib implements this in its GSubprocess API. Linux supports this with close_range() and many other OSs have a closefrom() syscall. Linux also has a fallback by iterating over /proc/self/fd using the async-signal-safe getdents syscall.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing the requested behavior with GLib's GSubprocess API and the platform mechanisms named here: Linux close_range(), closefrom() where available, and the /proc/self/fd getdents fallback. Define the standard-library API and platform behavior for closing all descriptors except an allowlist, with the design covering fork-to-exec safety and non-Linux systems.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- operating-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100