-
Notifications
You must be signed in to change notification settings - Fork 18
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
Why is this package needed? #23
Comments
Sure - it would work for most SysV based systems (dunno about windows *bsd). Also the ancestor processes in the container need not be directly started via this process. Process daemons, set sid or anything doing a PR_SET_CHILD_SUBREAPER prctl could potentially be outside this process chain. Now that said, a simple solution in a lot of cases would be to simply run an "init" process inside the docker container and |
That holds also if you handle SIGCHLD and wait on a process in signal's handler. It is exactly the same thing if you wait for SIGCHLD and non-discriminatory wait for any process (pid set to -1) in handlers or call explicitly Everything else you wrote holds. I am just saying that this implementation could be simplified by replacing the handler and a wait loop with simply calling |
If you ignore the signal, you will never be delivered that signal and you would be disabling it for the entire process. Example: User code could have a chain of signal handlers ala:
Death and Susan can have different ideas of what they want to do! |
Ignoring the signal is exactly the same as waiting for it and non-discriminatory reaping the process, not exposing any information about the waited process to the rest of the code (which what this library is doing). Especially because you do The example you shared is not complete. It is true that both Susan and death both are notified of SIGCHLD, but only one of them will be able to reap the process successfully, generally nondeterministically. Which means that for practical purposes, one cannot rely on those notifications to do anything useful with processes, except for just blindly reaping them, which could then be simplified to This is why you have section "Into The Woods" where you propose to have two processes. Because once you start non-discriminatory reaping children, that process becomes useless for any other handling of children processes. I have spent few days on this now. :-) In my own code (I am working on init system for Docker containers in Go, https://gitlab.com/tozd/dinit, still WIP) I have to expose metadata about reaped processes to the rest of the process so that if any other part of the code spawns a direct subprocess and fails to wait on it (which you can learn from |
No have to re-iterate this [again] (double redundancy!) - it is not the same, you are explicitly disabling signals - which has other ramifications as I explained in the example and explained below. Signals are a notification mechanism - reaping is something you can optionally do "after the fact" ... which this library does to prevent zombies. We can expose the information about the reaped processes - haven't had an ask as yet.
The example I shared was a stub to indicate what some downstream code could potentially do. It is useful if someone wants to be notified about children dying (which disabling the signals would prevent). |
If you have an example of what you are trying to do (some test code and the problems you are facing), that could be useful and maybe can suggest something. |
What else can you do after SIGCHLD signal except to reap the process? I think I am lacking imagination here.
Of course you had. This is why you have the "Into The Woods" section in the README. It was asked implicitly; running a subprocess in a Go program with this package enabled is not really possible and non-deterministic. If one dislikes the "make two processes" solution, one starts thinking about other solutions.
I agree, theoretically it demonstrates that, but because the example stops short of showing also two different things one could do responding to such an event, it stays very theoretical to me.
Oh, the problem is the one you described in the "Into The Woods" section. I want both to reap zombies and spawn subprocesses. Once I enable this library, spawning of subprocesses does not work anymore. It does not work in the same way as if I had I understand now that this library does not use Anyway, I do not think there is much usefulness if pursuing this discussion. We both described our viewpoints well. Thank you. |
SIGCHILD indicates a child processs has changed state. This can happen due to various other reasons - e.g. a process is suspended/resumed
... As re: the other points, as you mentioned there was not an explicit ask. I am more than willing to add something if there is an ask. I am sorry things did not work out for you. |
But
Oh, no. Things are working great for me. As I mentioned, I am writing my own init in Go for Docker containers (to address similar issues you described in this package, but few more features) so I was looking at your code for insights. And I thought it is doing something more so I needed to clarify why you are doing it this way. Thank you. |
Not in the Golang signal API but see: https://pkg.go.dev/syscall#WaitStatus returned by Wait4 |
And now we came full circle. :-) So you are saying that one should not just ignore |
I am not saying that. You asked me whether the |
Yes, and then the parent process which is doing reaping could be just |
If everything you want to do is just reap any zombies, then it is much easier to just do:
By explicitly setting
SIGCHLD
handler to ignore, you ask Linux to reap zombies for us. This then handles zombies for you. No need to make a loop and wait yourself.The text was updated successfully, but these errors were encountered: