0

How can I completely detach the child process from the parent process that is sharing a common cgroup?

Currently, I am achieving this by forking child again by doing ssh localhost but I want to avoid ssh localhost. I also tried daemonizing the child process but it seems it doesn't completely detach i.e. parent and child still share same cgroup. And since they are sharing the same cgroup hence sending a SIGKILL to parent process sends SIGKILL to child process as well.

ThinkGeek
  • 4,749
  • 13
  • 44
  • 91
  • Is cgroup sharing really the primary problem here, or is it actually that signals are delivered to more processes than you would like? – John Bollinger Apr 28 '20 at 12:08
  • Additionally, are you asking for a solution that can be applied externally, to (other) existing processes, or a way to make programs manage this for themselves? – John Bollinger Apr 28 '20 at 12:09
  • And are you sure that it's cgroups, not pgroups, that are relevant here? There are specific provisions for delivering signals to pgroups, but I'm uncertain about how that's relatated to cgroups. – John Bollinger Apr 28 '20 at 12:12
  • @JohnBollinger I actually daemonized the child process by following steps in https://www.oreilly.com/library/view/python-cookbook/0596001673/ch06s08.html and found that the only common thing between child and parent was cgroup and hence I think the same cgroup is the reason why SIGKILL is getting propagated to child. – ThinkGeek Apr 28 '20 at 12:33
  • In other words, yes, the problem is your daemon getting signaled when you don't want it to be. Please edit the question to clarify that, and please present a [mre] that demonstrates the issue. I am inclined to think that the problem indeed is *not* related to cgroups, but we can't determine what it is without reviewing a representative example of what you're doing. Including the mechanism you are using for signal delivery. – John Bollinger Apr 28 '20 at 12:38
  • I think your issue is not the cgroup, it is the teminal process group. If you are not detached from a terminal, then any signal sent by the terminal goes to all processes in the terminal process group (tpgid in ps) – stark Apr 28 '20 at 13:16

0 Answers0