[pulseaudio-discuss] Remaining PA process after X logout

Tanu Kaskinen tanuk at iki.fi
Wed Feb 28 15:39:34 UTC 2018


On Wed, 2018-02-28 at 16:21 +0100, Takashi Iwai wrote:
> On Wed, 28 Feb 2018 16:14:33 +0100,
> Tanu Kaskinen wrote:
> > 
> > On Wed, 2018-02-28 at 14:53 +0100, Takashi Iwai wrote:
> > > On Mon, 26 Feb 2018 12:20:03 +0100,
> > > Takashi Iwai wrote:
> > > > 
> > > > On Mon, 26 Feb 2018 12:06:50 +0100,
> > > > Tanu Kaskinen wrote:
> > > > > 
> > > > > On Mon, 2018-02-26 at 10:56 +0100, Takashi Iwai wrote:
> > > > > > On Mon, 26 Feb 2018 10:47:09 +0100,
> > > > > > Tanu Kaskinen wrote:
> > > > > > > 
> > > > > > > On Mon, 2018-02-26 at 10:20 +0100, Takashi Iwai wrote:
> > > > > > > > On Mon, 26 Feb 2018 10:12:44 +0100,
> > > > > > > > Tanu Kaskinen wrote:
> > > > > > > > > What about fedora? I somehow would expect fedora to be eager to adopt
> > > > > > > > > the socket activation feature in pulseaudio that has been available for
> > > > > > > > > a long time already.
> > > > > > > > > 
> > > > > > > > > If you're using pulseaudio under systemd, it seems weird if all user
> > > > > > > > > services don't get terminated on logout.
> > > > > > > > 
> > > > > > > > I guess they would hit the same issue.  But maybe there can be some
> > > > > > > > workaround.
> > > > > > > 
> > > > > > > I don't think the same issue would affect pulseaudio if it was under
> > > > > > > systemd control, unless the user instance of systemd keeps running for
> > > > > > > longer than logind keeps the runtime dir around. I'd be very surprised
> > > > > > > if that was the case. I had a look at systemd documentation, which
> > > > > > > confirmed to me that when the user instance of systemd shuts down, it
> > > > > > > will stop all services that haven't explicitly requested not to be
> > > > > > > stopped.
> > > > > > 
> > > > > > The man page of logind.conf seems wrong.  The default value of
> > > > > > KillUserProcesses is "no" in the recent versions, judging from the
> > > > > > configure.ac; i.e. systemd doesn't behave aggressively to kill user
> > > > > > processes at logout.
> > > > > > 
> > > > > > Maybe this setup can be the difference between distros?
> > > > > 
> > > > > The default value of KillUserProcesses can indeed cause differences
> > > > > between distros, because it was changed to "yes" a couple of years ago.
> > > > > I suppose you have an older version, since configure.ac doesn't exist
> > > > > any more (systemd uses meson as the build system nowadays). Also, some
> > > > > distros may have reverted the default back to "no" due to problems that
> > > > > KillUserProcesses can cause.
> > > > 
> > > > Yes, that's a plausible explanation of the differences.
> > > 
> > > ... and now I double-checked the behavior on openSUSE Tumbleweed, with
> > > the latest components.  By some reason, systemd doesn't kill PA no
> > > matter whether KillUserProcesses is set or not.  This is being
> > > tracked.  Meanwhile...
> > > 
> > > > > However, I'm not talking about KillUserProcesses in the quoted
> > > > > paragraph. I'm talking about the situation where there is a user
> > > > > instance of systemd running and managing pulseaudio. Pulseaudio ships
> > > > > .service and .socket files for systemd, which suse apparently doesn't
> > > > > use. If suse were to use those, then the user instance of systemd would
> > > > > manage the lifecycle of the pulseaudio daemon, and when the user
> > > > > instance of systemd shuts down on logout, it should stop all services
> > > > > it's managing (but not anything that it isn't managing). Logind's
> > > > > KillUserProcesses is a different thing, and it should enter the picture
> > > > > only if there's still something from the session running after systemd
> > > > > has shut down.
> > > > 
> > > > Ah good point.  I checked the openSUSE Tumbleweed, the latest rolling
> > > > release, and indeed it's using already the systemd stuff for starting
> > > > up.  It means that the issue is seen only with the older versions.
> > > 
> > > .... my statement here was incorrect.  The startup of PA wasn't
> > > changed with the latest package on openSUSE Tumbleweed, and it means
> > > that it's either started by XDG autostart (by pacmd), or autospawn by
> > > any program.
> > > 
> > > And once when PA gets started by either of these, the problem
> > > appears: PA process remains after X session logout.  If PA is started
> > > via systemd user service, it exits properly at X logout.  I could
> > > confirm the issue on XFCE, too.
> > > 
> > > That is, the current situation doesn't look good.  In the bugzilla,
> > > systemd guys suggested the quote from pam_systemd man page:
> > > 
> > > ENVIRONMENT
> > >        $XDG_RUNTIME_DIR
> > >            .... If a user logs in once, then logs out again, and logs
> > >            in again, the directory contents will have been lost in
> > >            between, but applications should not rely on this behavior
> > >            and must be able to deal with stale files. ....
> > > 
> > > So in pam_systemd POV, it is expected that PA won't fail even if it's
> > > restarted after the removal of $XDG_RUNTIME_DIR.
> > 
> > I wouldn't interpret the man page that way. The man page seems to be
> > saying that if pam_systemd *doesn't* remove $XDG_RUNTIME_DIR, then
> > pulseaudio is expected to handle the situation where there is some old
> > garbage in the runtime dir.
> 
> Erm, no, it says that it cleans up.  The full quote of the section:

Yes, it says that pam_systemd cleans up the directory, but the only
thing that it says about application expectations is that applications
shouldn't rely on the cleanup happening. The man page doesn't say
anything about what an application is supposed to do if its files are
removed while the application is still running.

> Anyway, are you willing to switch to systemd-managed pulseaudio in
> > suse? That seems to solve the problem. (Note that in that case you
> > should also disable autospawning to avoid confusing situations if the
> > user stops pulseaudio via systemd.)
> 
> I've been thinking of it, but one thing I noticed is that PA gets
> started even via remote login if we go with systemd user service.
> Is this expected?  This would bring a certain impact to users.

Whether it's expected depends on your configuration. If you have
configured the pulseaudio service to start always on login, then that's
expected. However, I think most distros use socket activation, so they
only enable the .socket unit, not the .service unit. With socket
activation, remote login shouldn't start pulseaudio unless there's some
program trying to use pulseaudio.

> And in anyway this can't be applied to the already released openSUSE
> Leap 42.3 (and maybe not for Leap 15.0) etc easily, only for the
> upcoming stuff.
> 
> > I wouldn't be opposed to an alternative solution either: module-
> > console-kit, module-systemd-login and module-x11-xsmp could set exit-
> > idle-time to 0 when the first session is detected. I think non-zero
> > exit-idle-time is only useful when we have no means to do session
> > tracking.
> 
> Due to the reason above, a fix without systemd user service would be
> greatly appreciated.

I'll write a patch.

-- 
Tanu

https://liberapay.com/tanuk
https://www.patreon.com/tanuk


More information about the pulseaudio-discuss mailing list