Open jordens opened 8 years ago
I figure the perfect solution here is to use job objects on Windows and cgroups on Linux, so that when the "root" exits, in any way whatsoever, the OS murders the rest of the processes it's grouped with. win32api from stdlib is the way to do this on Windows and cgroup-utils is the way to do this on Linux, although I'm not quite sure if the latter exposes all the knobs we need.
An easier solution without more dependencies/components may be to make sure that applets exit immediately when the other end of their IPC pipe is closed. This assumes 1) both Windows and Linux provide a sane API for this 2) Python's asyncio didn't mess it up. Those are nontrivial assumptions.
That doesn't handle the case where an applet is hung, and that also hangs the GUI because their message loops interlock, and the user exits the GUI process. (Although, does this actually happen with Qt window embedding? I'm pretty sure it happens with other frameworks...)
The rationale to have child processes in new sessions is here: https://github.com/m-labs/artiq/commit/fef72506e4a25e754172a885afbc05fc15530523 It still seems correct and desirable to have this behavior for ctlmgr and workers but maybe not for applets.
I suspect they only survive when a GUI actually crashes hard. They shoud not occur in other cases.
Can we/do we want to try to clean them up better?