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

10

u/calrogman May 29 '16 edited May 29 '16

As for the change itself - if a user has completely logged out of a system, why do they need processes still running tying up resources and leaving (potential) vectors for attack?

Just a few days ago, I started a long-running process (a dd operation) on a laptop running OpenBSD (which I recommend to anybody who has experienced regressions in systemd, as I have). I backgrounded this task (^Z, bg), checked (and inbox zeroed) my mail, and logged out - of note is that the default behaviour of OpenBSD's login shell is not to send sighup to backgrounded processes when the shell terminates. Some hours later, I logged in, checked ps, saw that the job had finished, and removed the hard drive which was being imaged.

What gives the systemd developers any right to break this reasonable, decades-old workflow? Why would I need to be logged in for the duration of this operation? It is a nonsensical change apparently solely motivated by an assumption that the user is brain damaged.

0

u/[deleted] May 29 '16

[deleted] — view deleted comment

4

u/calrogman May 29 '16 edited May 29 '16

This is also the default behaviour of FreeBSD's csh and sh, of Debian's dash and of GNU bash when invoked as sh.

Bash and zsh are the only shells I can think of where sending sighup to children is the default behaviour (and I might be wrong about zsh). Because of this, I suspect that when you say "coming from other Unices", what you mean is "coming from Linux".

3

u/eras May 29 '16

As you mention even in your use case you are relying on the fact that the login shell doesn't send SIGHUP to processes during output, which I don't consider a feature. Use nohup, (&), &|, disown of zsh, screen or tmux to explicitly leave those on the background. Or in the case of system having being configured to kill user processes upon exit, use systemd-run --scope --user. Maybe they should provide their own implementation of nohup.

So let's say you have a buggy piece of software. For example you have exited matlab using D and process remains, spinning CPU at 100% (I guess this bug has been fixed since). It would seem to me it's perfectly sane to kill processes upon logout that haven't been particularly requested to be backgrounded.

And while buggy apps don't necessarily consume 100% CPU, you might find that exiting a session on a typical Linux desktop leaves a bundle of useless processes lingering around for no reason.

It'll be more fun (spectatorwise) when this functionality covers SSH login sessions as well.. :-)

0

u/calrogman May 29 '16

I should have mentioned that the default action of not sending sighup to background processes can be changed using set +o nohup. I consider nohup an ugly hack to work around shells with poor job management. In the same way that I consider systemd-run --scope --user an ugly hack for "users who can't be trusted to do job control" or "the people who wrote Gnome".

OpenBSD does provide a nohup for use with brain damaged or misconfigured shells.

The use of screen or tmux to protect from a misconfigured shell, a single process which is expected to terminate at a later date and is not expected to require later input from the user, is folly. Now you have a tmux or screen process hanging around forever when it has no need to be there.

For example you have exited matlab using ^D and process remains, spinning CPU at 100% (I guess this bug has been fixed since).

It would seem to me perfectly sane to expect the user to kill such a process using the job management facilities available to them.

And while buggy apps don't necessarily consume 100% CPU, you might find that exiting a session on a typical Linux desktop leaves a bundle of useless processes lingering around for no reason.

I don't use Linux on the desktop. I have never had this problem with my OpenBSD desktops though. Probably because I don't use Gnome.