On Fr, 2016-05-27 at 15:29 +0100, Tom Hughes wrote:
> On 27/05/16 15:25, Chris Adams wrote:
> > Once upon a time, Lennart Poettering <mzerq...@0pointer.de> said:
> >> I am pretty sure we should consider it our duty as Fedora developers
> >> to improve the Linux platform, and I am pretty sure that properly
> >> cleaning up processes on logout is a step towards that, not against
> >> it.
> >
> > When you "clean up" by killing things that are designed to run after
> > logout, you are being over-zealous.  It is incumbent upon you to fix
> > your cleanup methods to handle this case, not the thousands of users
> > to change their process to avoid your broken methods.
> 
> But that's effectively calling for the impossible - if there has 
> historically been no way for things to announce that they are expected 
> to remain after exit then there's no way to magically identify them now.

Wrong.

There is a way, and it's called SIGHUP.  Processes get that signal if
your controlling terminal is gone, which typically happens for
background processes on logout.  Default action for the signal is to
terminate the process.  So if you run "tail -f $somelog &", forget about
it, then logout (or close the xterm) the SIGHUP will kill it.

But it's also possible for programs to ignore and/or handle SIGHUP.
Simplest case is the "nohup" utility which basically sets the SIGHUP
action to ignore then goes execute whatever you specified on the command
line.  IIRC vim catches SIGHUP to save the current buffer somewhere
before exiting so your unsaved work isn't lost.  And of course tools
like screen and tmux don't exit but simply detach from terminal on
SIGHUP.

There is nothing simliar for gui processes (which typically don't have a
controlling tty) though.  But having gui processes continue when your
display server is gone looks pretty pointless to me, except for
save-state-then-exit style actions (like firefox does so it can offer to
restore tabs next time you start it).

IMO systemd should allow to specify the KillUserProcesses policy
separately for processes with/without controlling terminal.  So you
could ask systemd to zap any gnome process going wild on logout without
breaking screen and tmux.

While being on it:  I also think a logging option would be useful.  If a
(gui) process doesn't exit by itself on logout but needs to be killed
this indicates a bug and you might want to know about it.

cheers,
  Gerd
--
devel mailing list
devel@lists.fedoraproject.org
https://lists.fedoraproject.org/admin/lists/devel@lists.fedoraproject.org

Reply via email to