-
Notifications
You must be signed in to change notification settings - Fork 621
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Could not fork too many open files
Depending on the system when about to have 497 open forks with an file descriptor open than a: ``` sd main:WARNING:2022-09-21 08h52.59 utc:215235: Error : could not fork ! Error : Too many open files ``` occurs which results in an interrupted scan. The reason for this are: 1. there was no handling in the parent process to close the fd 2. unfortunately plugins may exit instead of returning 3. the cache is not verified regulary if the process for the fd is running 4. the ipc cache was growing indefinitely To solve the 1. case a signal SIGCHLD is send to the parent process when the given function exit to trigger a ipc_close for that process. To solve the 2. and 3. case there is a new function `close_ipc_fd_on_unnoticed_exit` to close ipc when a process is not running anymore. This function is called twice. Once before the fork call is executed to close unneeded fd and on EMFILE || EAGAIN after forking in a loop to retry forking after cleaning up unneeded fd. To solve the 4. case we check the cache upfront if there are closed ipc cached and reuse those instead of a just appending new ipc.
- Loading branch information
1 parent
aed0474
commit 354c42a
Showing
3 changed files
with
77 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters