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

9

u/[deleted] May 28 '16

It's extra code on possibly hundreds of projects just so that one project (Gnome) doesn't have to fix their bugs.

What does this have to do with Gnome? Plenty of applications wouldn't get cleaned up properly when logging out if that is what you are referring to.

33

u/[deleted] May 28 '16

lol, that's literally a gnome bug

21

u/lolidaisuki May 28 '16

Plenty of applications wouldn't get cleaned up properly when logging out if that is what you are referring to.

But most applications won't break because of it. The fact that Gnome does is problem with Gnome, nt every other package ever.

13

u/[deleted] May 28 '16

At the point where random processes are left running when a user logs out I'd call that 'undefined behavior' so sure sometimes that does or doesn't cause problems but it is a real issue IMO.

9

u/Lennartwareparty May 28 '16

It's not undefined, it's completely defined what the semantics are and what happens.

24

u/redrumsir May 28 '16

And if it was unintended to have those processes not terminate on logout ... then one should fix that issue, rather than changing a long-time default behavior. Fix the bugs where they are, don't have a blanket fix of the symptoms.

Why? If it isn't obvious:

  1. It will still be a bug on non-systemd systems.
  2. It will still be a bug on systemd systems that set up systemd to have KillUserProcesses=No. Which, if I used systemd is what I would do. I often create jobs that run 24/7 for a week or more.

3

u/[deleted] May 28 '16

I can certainly agree that if there is a specific application having this issue they should fix it on all platforms but I don't think that this change is inherently bad moving forward though.

12

u/redrumsir May 28 '16

You are OK with breaking the behavior of daemon (http://linux.die.net/man/3/daemon ) or do you think that daemon needs to have systemd-specific code to keep its specified behavior.

6

u/[deleted] May 29 '16 edited May 29 '16

If you go purely off of the description there:

The daemon() function is for programs wishing to detach themselves from the controlling terminal and run in the background as system daemons.

Then I think in order to be a "system daemon" in this case would require interfacing with systemd since it manages your systems daemons.

As a user though I prefer more explicit behavior so users know what will and will not run beyond their users session. I admit I do not know what the ramifications of amending that description to be "user daemon" on systemd would be though since most services should be configured properly already.

9

u/redrumsir May 29 '16

The daemon() function is for programs wishing to detach themselves from the controlling terminal and run in the background as system daemons.

Don't get hung up on the word "system daemons". It's for any daemonization ... not just for systems daemons. It's what tmux uses. This long-standing behavior for that API/call will be broken by systemd changing the default.

This change to systemd will break longstanding behavior ... all to handle a symptom of some other broken programs (bug report indicated that a GNOME session wasn't cleaning up after itself on logout). I say they should fix the actual problems, instead of breaking the daemon call.

1

u/webpigeon May 28 '16

That's not quite correct - a daemon would not have this issue as it would not be running under the user's session. If it is then the daemon is already misconfigured (it should be running under a system account, with the process controlled by the init system itself rather than the user's session). This has been the way in which services have always been run (under both system v init and systemd).

This change effects processes designed to run after their associated session has terminated.

6

u/redrumsir May 29 '16

The daemon call is exactly what tmux uses to detach itself. And this behavior would be broken by the proposed default systemd setting.

There are tons of reasons that regular users would want to daemonize something. I do it all of the time.

4

u/webpigeon May 29 '16

I can see that the code uses the function (and even has a compat version of the function in case it's not supported). Tmux is not trying to be a system daemon, it just wants to stick around past the session's demise. A much cleaner way of doing it would be to have it start a separate session.

It's much cleaner to have real daemons managed by the init system rather than forking and exiting the parent process a few times. Processes which do this are difficult to look after correctly. It's also much cleaner for logging and management.

I'm not saying that users shouldn't be able to have long running detached processes, I look after servers (using screen for long running tasks which I can check back on later) and run long running tasks as a user on a cluster (running calculations which the results can be collected from later). At the same time I'd rather that badly written code which doesn't correctly clean up after itself is not left to linger after the user has logged out (can you imagine an environment like a university where the computer is used by 20 or 30 students in a 24 hour period and perhaps rebooted once a week?). No, the code shouldn't be buggy and should clean up after itself but code which doesn't is already out there, running on systems.

Programs which are legitimately needing to stick around need a way of telling the system that but doing it in a way which is transparent to the init system is a good idea. This strategy also appears to be creating the components needed to make the program a legitimate, system managed, process. It also makes it easier to write policies which permit some users running detached tasks but not others.

The init system knows what is around, why it is around and what happened to make it stick around. There are other parts of this comment thread that detail how, as a user, you would be able to run a long running (detatched) process using systemd. The systemd developers asked to include part of this new code in tmux, it's a Free Software project, anyone can ask for features or make recommendations - that's one of the things which makes the Free Software community great. Imho, it's not a bad thing that they realised that their change could cause an issue and are looking to make sure that issue doesn't become a problem for end users. The Debian maintainer also seems to believe this is worthy of inclusion.

If you believe that it's going to be a problem for you and you want the old behaviour, you are free to edit the configuration on your machines. The proposed change seems like a sensible default me. If the issue is an extra (optional) compile time dependency on dbus, pam or some systemd lib then I guess that the distros could always patch the code themselves - but that seems like a lot of duplication of effort. The fact the proposal included a optional compile time flag does seem to make this argument a bit moot though.

tl;dr nothing about this change stops you running detached processes, the systemd developers could have just changed it and not tried to warn other projects, your detached processes would have terminated on logout and everyone would be complaining about them not doing enough to let people know.

-1

u/redrumsir May 29 '16 edited May 29 '16

If you believe that it's going to be a problem for you and you want the old behaviour, you are free to edit the configuration on your machines.

  1. What if I'm not the sysadmin and simply want the daemon call to behave as it always has? It seems rude/stupid that this long-standing functionality of this call has been broken by a default setting in an init. My typical behavior is to remote in to work (I'm not the admin), check on the status of some jobs, trigger a few more jobs depending on the results, and log out.
  2. I don't use systemd, so systemd's issues/settings isn't a problem for me unless programmers begin to assume that all user processes are killed on logout. The issue is that the problem of unintended zombie or NOHUP'd processes that aren't cleaned up should be fixed where it is: The program(s) [in this case a GNOME but report was referenced] that create these and then doesn't clean them up. That's the real issue ... and they aren't going to fix the real bug if systemd treats the symptoms of the real problem.
→ More replies

6

u/lolidaisuki May 28 '16

You'd call it undefined, but it's often intentional. People leave processes running on the background on purpose.

10

u/[deleted] May 28 '16

And users can still explicitly do this.

20

u/redrumsir May 28 '16

And when they do this by setting KillUserProcess=No ... then those GNOME processes that should have terminated/cleaned themselves will still be a bug. Fix the problem, not the symptom.

-2

u/Regrenos May 29 '16

You can turn the "don't kill this" option on at a per process granularity. If you're going to bitch and moan, at least take the time to read just a little bit about what you're talking about.

1

u/redrumsir May 29 '16

Don't bitch/moan at me until you read what I wrote: One should fix the root of the problem, not use a big band-aid to handle the symptoms. The problem is the programs that leave unintended processes around. If you read/learned about Unix signals ... there is no reason why a properly functioning program should unintentionally leave detached or NOHUP'd shit lying around.

→ More replies (2)

-2

u/totallyblasted May 28 '16

So, buggy behaviour is ok as long as it is sometimes intentional?

Ima gonna start writing to NULL pointers and call it intentional now. Why even bother fixing when you can simply insert intentional behaviour

6

u/lolidaisuki May 29 '16

So, buggy behaviour is ok as long as it is sometimes intentional?

Having background processes is not buggy behaviour. However killing everything is.

-1

u/totallyblasted May 29 '16

There is a big difference between running and unwanted remnant.

3

u/lolidaisuki May 29 '16

There is a big difference between running and unwanted remnant.

Yes. One is common, and one is very rare.

1

u/totallyblasted May 29 '16

Yet, it is much simpler handle first properly than avoid the second

10

u/Lennartwareparty May 28 '16

No, it's by definition not buggy behaviour if it's documented and intended.

A bug is behaviour of a program that is against documentation and intention. Calling behaviour you simply don't agree with a 'bug' is ridiculous.

→ More replies (14)