Skip to content
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

Sub-processes aren't in the same process group #8

Open
sheerun opened this issue Nov 20, 2017 · 4 comments
Open

Sub-processes aren't in the same process group #8

sheerun opened this issue Nov 20, 2017 · 4 comments

Comments

@sheerun
Copy link

sheerun commented Nov 20, 2017

Because subprocesses aren't in the same process group as hivemind, when hivemind gets killed for some reason, the subprocesses arn't killed and are disowned instead.

Could you please spawn subprocesses in the same process group?

@DarthSim
Copy link
Owner

Processes have to be run in their own sessions because of PTY. It's not possible to run a process in a different session but the same group ID. Correct me if I'm wrong.

@sheerun
Copy link
Author

sheerun commented Nov 20, 2017

You're correct. According to this stackoverflow, it seems the solution would be to use:

  1. On Linux set Pdeathsig to syscall.SIGTERM
  2. On other platforms run intermediate child that pools whether its ppid is 1. If it is it means parent died and it should send SIGTERM to supervised process (you can also use other tricks like kqueue or sharing pipe that gets closed when parent dies, but it seems there's no solution without using intermediate process).

@sheerun
Copy link
Author

sheerun commented Nov 20, 2017

Or you cold record spawned pids and kill / reattach to them when running second time after crash. Of course it would leave these processes running until hivemind is started again. Not sure which solution is worse, but probably both better than allowing sub-processes to run indefinitely after hivemind crashes or gets killed.

@DarthSim
Copy link
Owner

Added Pdeathsig to v1.0.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants