Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
How to shut off pipewire/wireplumber cleanly ?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Multimedia
View previous topic :: View next topic  
Author Message
dmpogo
Advocate
Advocate


Joined: 02 Sep 2004
Posts: 3364
Location: Canada

PostPosted: Sat Aug 24, 2024 2:54 am    Post subject: How to shut off pipewire/wireplumber cleanly ? Reply with quote

Here is another twist: when I run a kde, pipewire/wireplumber starts somehow run under my name as user. Now I exit the desktop, stop display-manager, pipewire/wireplumber is still running.
Given that this is not an init service, what is the proper way to shut them off, outside of kill -9 which is a crude way ?

Why do I need it? I want to unmount /home partition to do some filesystem maintenance. Wireplumber/pipewire are the only processes that keep /home busy after I close kde and switch to console
Back to top
View user's profile Send private message
Zucca
Moderator
Moderator


Joined: 14 Jun 2007
Posts: 3618
Location: Rasi, Finland

PostPosted: Sat Aug 24, 2024 8:10 am    Post subject: Reply with quote

I have (had) pretty much the same problem. In my case I needed to umount tmpfs mounts for users who have logged out and do not have any process running that is connected to any tty.
My, crude, solution is to basically run the following
Code:
pgrep -u "$USER" -x 'pipewire|wireplumber' 1>/dev/null 2>&1 && pkill -u "$un" -x 'pipewire|wireplumber'
although
Code:
pkill -u "$un" -x 'pipewire|wireplumber'
alone should be enough.

The interesting thing with pipewire (and wireplumber) is that upon logging out, those processes do sometimes stop, but sometimes (seems like more often) they continue running in the background. I haven't had time to investigate that, hence the crude way of using pkill.
_________________
..: Zucca :..
Gentoo IRC channels reside on Libera.Chat.
--
Quote:
I am NaN! I am a man!
Back to top
View user's profile Send private message
dmpogo
Advocate
Advocate


Joined: 02 Sep 2004
Posts: 3364
Location: Canada

PostPosted: Sat Aug 24, 2024 8:19 am    Post subject: Reply with quote

Right, I'll of course pkill for now, but overall it looks like misdesign. After a user is logged out, no user owned processes should be left behind. I did not even think how ugly it is on a multiuser shared machines, if there are still user processes running after the user is gone.
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 22395

PostPosted: Sat Aug 24, 2024 1:44 pm    Post subject: Reply with quote

I suspect this is unfortunate fallout of systemd's misfeature KillUserProcesses (see man logind.conf). On systems where systemd-logind (or equivalent) has that enabled, these orphans are automatically killed off, so there is no pressure on the developer to ensure it exits properly at the right time. On systems without that automated kill, the developer needs to get this right.
Back to top
View user's profile Send private message
Zucca
Moderator
Moderator


Joined: 14 Jun 2007
Posts: 3618
Location: Rasi, Finland

PostPosted: Sat Aug 24, 2024 2:36 pm    Post subject: Reply with quote

Hu wrote:
I suspect this is unfortunate fallout of systemd's misfeature KillUserProcesses
I wonder how this is handled when this setting is set to no/false? Is pipewire still left running?
(I also wonder if that setting still kills any terminal multiplexer sessions the user has running...)

I've implemented something close to KillUserProcesses, but it checks if any program is connected to a tty or if the binary has 'tmux' in their filename, then acts accordingly.
I think this is "best at the moment" what I could came up with.
_________________
..: Zucca :..
Gentoo IRC channels reside on Libera.Chat.
--
Quote:
I am NaN! I am a man!
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 22395

PostPosted: Sat Aug 24, 2024 3:19 pm    Post subject: Reply with quote

The manual page specifically warns:
Code:
           Note that setting KillUserProcesses=yes will break tools like
           screen(1) and tmux(1), unless they are moved out of the session
           scope.
So yes, either the user needs to remind systemd not to kill them, or those tools need special handling to inform systemd not to kill them.

As for whether pipewire remains running, I do not know. I have never needed more than basic ALSA, so I do not have pipewire running.
Back to top
View user's profile Send private message
dmpogo
Advocate
Advocate


Joined: 02 Sep 2004
Posts: 3364
Location: Canada

PostPosted: Sat Aug 24, 2024 4:21 pm    Post subject: Reply with quote

Zucca wrote:
Hu wrote:
I suspect this is unfortunate fallout of systemd's misfeature KillUserProcesses
I wonder how this is handled when this setting is set to no/false? Is pipewire still left running?
(I also wonder if that setting still kills any terminal multiplexer sessions the user has running...)

I've implemented something close to KillUserProcesses, but it checks if any program is connected to a tty or if the binary has 'tmux' in their filename, then acts accordingly.
I think this is "best at the moment" what I could came up with.


It is an interesting situation overall. In principle, there are reasons for some user processes to be left running after logout. First of all, it may be their own code computing something for days :) All our favourite "nohup" options (by the way how systemd KillUserProcesses interact with nohup ? ) Then screen or tmux, and, similarly, I have for years Xvnc running on my office desktop for access, logged in or not. So KillUserProcesses cannot be used lightly or blindly, but at least it is some configuration option to impose a particular behaviour. I guess with openrc we have no control? Should it be elogind job ?

Now when piperwire will be used for the desktop sharing, one may, presumably want an instance running in the role of Xvnc ? But for now it seems closer in scope to X running as user or windowing (kwin) desktop service that should quit with the desktop session.
It is interesting since we have years of discussion and design of seats, sessions paradigm, etc, beyond standard UNIX multiuser setup, and it is still convoluted.

Now looking in more detail, I see that in case of KDE wireplumber is one of childs of plasma_session, so one would think it is plasma_session job to clean up on exit, or to have a configuration option whether to shutdown wireplumber
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 22395

PostPosted: Sat Aug 24, 2024 4:53 pm    Post subject: Reply with quote

I think elogind can also implement KillUserProcesses, yes. I completely agree that summarily killing all user processes is wrong, because as you say, there are processes where it makes sense to leave them around for later.

My earlier comment was speculating that wireplumber gets this wrong because, on systems that use KillUserProcesses=true, the forced kill cleans up the wireplumber, so the developers involved did not see a reason to include code to cause wireplumber to exit gracefully on logout. It's also possible that wireplumber is lingering because it believes (possibly correctly, possibly not) that some client process is still using it, and that you need it to remain so that you can continue to get sound after logout.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Multimedia All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum