r/linux • • May 28 '16

systemd developer asks tmux (and other programs) to add systemd specific code

https://github.com/tmux/tmux/issues/428
359 Upvotes

509 comments sorted by

View all comments

Show parent comment

24

u/ShadowPouncer May 29 '16

I commented on a child comment, but this really belongs here:

Absolutely anything launched from an interactive terminal session, regardless of if it's a local terminal or ssh or something else, has had a method to deal with this for an exceptionally long time.

As mentioned in other comments, it is called SIGHUP, and it is sent when the controlling terminal 'hangs up'.

The default action of SIGHUP is to terminate the process.

Anything that either disconnects from the PTY or intercepts SIGHUP is already taking steps to prevent itself from being killed on logout, and that should not be overridden by systemd just because the GUI world needs a similar solution.

3

u/flying-sheep May 30 '16

but that doesn’t carry semantics about the end of the user session, only about the moment the terminal disconnects.

when you start ssh-agent and tmux, the former should die at logoff and the latter not. yet there’s no API to mark which should behave how.

3

u/ShadowPouncer May 30 '16

If ssh-agent wants to die at logoff, it should not catch SIGHUP, and it should not detach from it's controlling terminal.

Both catching SIGHUP and detaching from the controlling terminal take active work, so it already takes an active decision, via a standard POSIX API, to decide to remain running in a terminal session after the user session terminates.

https://en.wikipedia.org/wiki/SIGHUP

Now, you could argue that ssh-agent has decided to do these things when it should not have, but the point is that it has decided to do these things, and this is a wheel that really doesn't need to be reinvented.

1

u/flying-sheep May 30 '16

why should it stay attached to its terminal? it’s a daemon, it doesn’t output things, and it should stay active in the background until logoff.

that’s what it wants to do. it also stays after logoff, but that’s unintentional.