[pulseaudio-discuss] [RFC PATCH] inotify-wrapper: Quit daemon if pid file is removed
tanu.kaskinen at linux.intel.com
Mon Jun 3 01:50:42 PDT 2013
On Fri, 2013-04-19 at 08:37 +0200, David Henningsson wrote:
> On 04/17/2013 05:56 PM, David Henningsson wrote:
> > XDG_RUNTIME_DIR is deleted on logout (according to xdg spec), and
> > that's where we keep our pid file and native protocol socket.
> > When these two files are deleted, it makes no sense to run anymore,
> > so quit. Hanging around is not only sloppy, but can also be harmful:
> > e g, if esd compat module is loaded, it will bind to the esd address.
> > When a new pulseaudio process is created on next login of the same
> > user, pulseaudio cannot start because the esd address is occupied.
I'll start by clarifying one thing: "session" means here the time when a
user is logged in in one way or another. There may actually be multiple
overlapping login sessions, but when talking about XDG_RUNTIME_DIR, one
"session" may cover multiple login sessions.
To avoid races, I think things should work like this:
1. A new session is created.
2. PulseAudio starts and "joins" the session somehow (maybe configured
to be a part of the session, or maybe started manually - both ways
3. Session shut-down is initiated.
4. PulseAudio quits.
5. The system removes the runtime directory after all session daemons
have exited, or after a timeout if the daemons don't exit quickly
Removing the runtime directory while it's still being used sounds like a
bad idea. Also, if the session doesn't wait for the daemons to exit
before ending, the daemons may still be running (perhaps in process of
shutting down) when the next session starts. That doesn't sound good
So, to me it sounds like the session manager is currently broken, and
your patch works around that brokenness. Therefore, I don't think your
patch should be included, unless the session manager developers say that
the session manager is not broken and will not get fixed and the only
way to know about the session shut-down is to monitor the runtime
We already have ConsoleKit and systemd-logind integration. I would have
imagined that they are sufficient, but I guess those have two problems:
1) when the session ends, PulseAudio will wait 20 seconds before
exiting, and 2) the session manager doesn't wait for PulseAudio to exit.
If our ConsoleKit/logind modules are the way to manage the lifetime of
the daemon, I guess we could and should fix at least the 20 second
More information about the pulseaudio-discuss