-
Notifications
You must be signed in to change notification settings - Fork 162
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
Allow disabling of GAP's SIGCHLD handler #3380
Comments
Just to extend on this, on initial inspection I think the GAP kernel does clean up after itself. Someone else should carefully check that there is no way for childPID in particular to be leaked. After that the big issue is the IO package. Unfortunately I think the fix there will be large and expensive:
This will make various things much more expensive, as we'd be changing a single waitpid(-1) for an O(n) pass over all child PIDs. We'd have to benchmark to see how much more expensive and if the cost is reasonable for standard GAP usage. |
To clarify: for the purposes of SageMath, the fact that |
Yes, but I'm trying to treat this issue more generally than just as it applies to Sage. |
Are there actual use cases involving a large number of child processes that need to be checked frequently? On my (relatively old) Linux laptop, a single |
Cross-reference: gap-packages/io#5 |
Per discussion toward the end of #3072, for the sake of embedding libgap in other systems, it should be possible for the
SIGCHLD
handler installed by GAP to be disabled, probably by setting the same flag that was added in #3072.The current implementation of the
SIGCHLD
handling is problematic (seeChildStatusChanged
, because it callswaitpid(-1, ...)
for any zombie child processes that might still be hanging around un-waited-upon. This is done because historically, some GAP code that launched child processes was less consistent about keeping track of their PIDs, and properlywait()
-ing on just those PIDs. Hence a blanketwaitpid(-1)
sweep to clean up any child processes that might be hanging around.The problem with this from an embedding perspective is that programs which embed libgap may run and manage their own subprocesses which have nothing to do with those started by GAP code, and having GAP call
wait()
on those processes could interfere with their management by the code that started them.We should make sure there are no more areas in the core GAP kernel or libraries that leave around zombie child processes. If there are any packages that somehow do this, responsibility of fixing the issue should be pushed on to that package.
Then the only question is whether the
handleSignals
flag should disable GAP'sSIGCHLD
handling completely. And if so, as GAP does still (IMO legitimately) useSIGCHLD
handle the completion of processes it is tracking, it should be documented how software which embeds libgap can/should integrate eitherChildStatusChanged
orCheckChildStatusChanged
into its ownSIGCHLD
handling.The text was updated successfully, but these errors were encountered: