3 ms·
> fork() also clones all the filedescriptors that might be open to the child. ... Easy way to cause too many open files errors. fork() cannot fail with EMFILE
by geocar 9y ago
> fork() also clones all the filedescriptors that might be open to the child. ... Easy way to cause too many open files errors.
fork() cannot fail with EMFILE or ENFILE[1]
[1]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/fork.html#tag_16_156_05 http://pubs.opengroup.org/onlinepubs/9699919799/functions/fo...
> It is the resposibility of the forking code to close filedescriptors it doesn't need.
FD_CLOEXEC can cause exec() to close file descriptors automatically.
> A parent process when it exits, requires that all child processes exit as well.
This is not true
- bluejekyll 9y ago> fork() cannot fail with EMFILE or ENFILE[1] This is true. But if you believe you're only closing files or sockets in the child process, then running into this issue is very simple. > > A parent process when it exits, requires that all child processes exit as well. > This is not true Sorry, you're right I was thinking of the SIGHUP to the child, it doesn't actually require an exit.