r/linux • u/rain5 • May 28 '16
systemd developer asks tmux (and other programs) to add systemd specific code
https://github.com/tmux/tmux/issues/428
359
Upvotes
r/linux • u/rain5 • May 28 '16
View all comments
Show parent comment
18
u/inhuman44 May 29 '16 edited May 29 '16
As you point out these are two different things. There are processes that can be sent to the background with & or Ctrl-Z that still run in the same session. These should be killed by the process manager when the session ends.
Separately there are processes that are launched in to their own session and should be killed on that sessions end, not on user log out. Programs like nohup and tmux do this.
But the way this is done with double forking is just crazy. Double forking is just a hack to fuck up the process tree and orphan the process. But what kind of process management system gets befuddled by this? One level of forking is okay, but two levels and it gets confused and doesn't know where to place it in the process tree? Garbage. The way it's done now is just a hack that exploits poor process management. And instead of fixing this glaring flaw we are supposed to just cross our fingers and hope that double forking never happens by accident? We already know that this happens by accident! No, if you want to keep your process alive after the session ends you should be telling the process manger that this is your intention, not exploiting a design flaw.
Which brings us full circle. It's not systemd's fault that previous systems couldn't track processes properly, it's not systemd's fault that programs sprung up that take advantage of this flaw. They are doing things the right way, fixing an obvious issue, and providing a migration path for programs that used the double forking hack. That's the whole point of writing a new PID 1, to fix issues like this.