You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Maybe something like forking, calling prctl(PR_SET_CHILD_SUBREAPER) in the forked process and then running the command from this forked process would help with reliably killing grandchildren. I think you could then kill all the command with all children and grandchildren by killing all children of the forked process until no children are left. Normally when a parent process dies, all children get init as new parent. PR_SET_CHILD_SUBREAPER instead causes the process which called it to be the new parent for all childprocesses and their children of the process using this syscall if a parent process dies. This also means that this process is responsible for calling wait on all zombie childprocesses when it receives SIGCHLD. I haven't actually checked if this scheme works though.
Edit: others also suggested this on HN. Should have scrolled down a bit. 🤦
The text was updated successfully, but these errors were encountered:
I could be mistaken, but my impression is that using PR_SET_CHILD_SUBREAPER means the process needs to be prepared to handle SIGCHILD from grandchild processes. But my assumption has been that setting / relying on global signal handllers is a non-starter for a library, which might need to run in-process with any number of other libraries with similar ideas. Curious to get folks' thoughts.
Maybe something like forking, calling
prctl(PR_SET_CHILD_SUBREAPER)
in the forked process and then running the command from this forked process would help with reliably killing grandchildren. I think you could then kill all the command with all children and grandchildren by killing all children of the forked process until no children are left. Normally when a parent process dies, all children get init as new parent.PR_SET_CHILD_SUBREAPER
instead causes the process which called it to be the new parent for all childprocesses and their children of the process using this syscall if a parent process dies. This also means that this process is responsible for calling wait on all zombie childprocesses when it receives SIGCHLD. I haven't actually checked if this scheme works though.Edit: others also suggested this on HN. Should have scrolled down a bit. 🤦
The text was updated successfully, but these errors were encountered: