Project

General

Profile

Actions

Bug #37500

closed

Killing of spawned processes isn't 100% reliable

Added by Adam Ruzicka 6 months ago. Updated 5 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
-
Target version:
-
Difficulty:
Triaged:
No
Found in Releases:

Description

Currently we spawn a somewhat deep hierarchy of processes.

For a simple "while true; sleep 1; done" we spawn something like this

bash(28973)─┬─sh(28992)───sudo(28995)───sudo(28999)───sh(29000)───sleep(29174)
└─tee(28993)

As part of the preparation, we stored pid of the second-level shell (28992 in this case). When the job is cancelled (be it by the user or because the timeout to kill was reached), we send a SIGINT to all processes which have the second-level shell as its parent - in this case sudo(28995) and then rely on that process to either pass the signal to its children and so on. Sadly this isn't completely reliable and the leaf processes can stick around and just be re-parented under init.

If we lean into some features provided by the kernel (namely namespaces), we should be able to make this much more reliable at least on platforms which support this.

Actions

Also available in: Atom PDF