4 ms·
Thanks. I'm still surprised because in my fuzzy memory the shell after forking keeps only the stdin/stdout/stderr fds open by the time it execs the command -- b
by abecedarius 3y ago
Thanks. I'm still surprised because in my fuzzy memory the shell after forking keeps only the stdin/stdout/stderr fds open by the time it execs the command -- but it makes sense that you could arrange to make this work with a different setup.
BTW if we're making changes like that, you could also make I/O redirection the responsibility of a command instead of the shell, similar to this article's 'if' command. I wonder how much else you could take out of the shell.
- ithkuil 3y agoThe O_CLOEXEC flag of open (and FD_CLOEXEC flag of fctl) can help you control which file descriptors will be automatically closed on exec. Otherwise, you have to manually close the files between a fork and an exec.