Skip to main content
Topic solved
This topic has been marked as solved and requires no further attention.
Topic: [SOLVED] [runit] Pipewire crashes after suspend (Read 3855 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

[SOLVED] [runit] Pipewire crashes after suspend

Hey guys,

I've encountered another problem for which I couldn't find a solution yet. So I am using XFCE without a DisplayManager, i.e. I am logging in through tty1 and autostart startx via .bash_profile. So for Pipewire to work, I start it on startup through .xinitrc:
Code: [Select]
pipewire &
pipewire-pulse &
pipewire-alsa &
wireplumber &
xrdb ~/.Xresources
exec startxfce4

Everything works fine until I close my laptop lid which causes my machine to suspend. Afterwards, when I want to continue to work, everything works except audio. Pipewire does not work anymore and starting it manually gives me some error messages:

Code: [Select]
$ pipewire
[E][00460.402869] mod.protocol-native | [module-protocol-:  610 lock_socket()] server 0x560a356e9d70: unable to lock lockfile '/run/user/1000/pipewire-0.lock': Die Ressource ist zur Zeit nicht verfügbar (maybe another daemon is running)
[E][00460.403116] pw.conf      | [          conf.c:  412 load_module()] 0x560a356ac5f0: could not load mandatory module "libpipewire-module-protocol-native": Die Ressource ist zur Zeit nicht verfügbar
[E][00460.403362] default      | [      pipewire.c:  123 main()] failed to create context: Die Ressource ist zur Zeit nicht verfügbar

So as it seems, Pipewire is still running but not properly anymore. I have searched the Arch wiki entry and the Internet for a clue on how to maybe automatically restart the service but so far I could not find anything useful, or if this would even be the proper solution. So now I have to ask you, guys, what can one do in this situation?

Edit: The solution to this problem is to disable bluetoothd because as of version bluez-5.63-1 it interferes with wireplumber (and pipewire-media-session) causing wireplumber to crash when waking up from suspend.


Re: [runit] Pipewire crashes after suspend

Reply #2
If it is your .xinitrc you need first to rtfw.
Also you need to run your DE in a dbus session so you need to actually exec dbus-launch

Re: [runit] Pipewire crashes after suspend

Reply #3
Thanks a lot for your help!


So basically I have to symlink pipewire and wireplumber to /usr/lib/elogind/system-sleep such that elogind can handle to execute them again after suspend?

If it is your .xinitrc you need first to rtfw.
Also you need to run your DE in a dbus session so you need to actually exec dbus-launch

Sorry, I could not understand the first sentence since I do not know the abbreviation "rtfw".
Regarding your second point: I have activated the dbus-runit service. So I still need to add "exec dbus-launch" to my .xinitrc? And if I am right, I have to add it before "exec startxfce4"?

Re: [runit] Pipewire crashes after suspend

Reply #4
Sorry, I could not understand the first sentence since I do not know the abbreviation "rtfw".
https://searx.be/search?q=rtfw

Relevant: https://wiki.archlinux.org/title/Xinit#Configuration
Quote
Remember that lines following a command using exec would be ignored.

This is because
Code: [Select]
$ man bash
then type literally /^ +exec (space at the end, then Enter):
Quote
       exec [-cl] [-a name] [command [arguments]]
              If command is specified, it replaces the shell.  No new process is created.  The arguments become the arguments to command.  If the -l option is supplied, the shell  places
              a  dash  at the beginning of the zeroth argument passed to command.  This is what login(1) does.  The -c option causes command to be executed with an empty environment.  If
              -a is supplied, the shell passes name as the zeroth argument to the executed command.  If command cannot be executed for some reason, a non-interactive shell exits,  unless
              the  execfail  shell  option is enabled.  In that case, it returns failure.  An interactive shell returns failure if the file cannot be executed.  A subshell exits uncondi‐
              tionally if exec fails.  If command is not specified, any redirections take effect in the current shell, and the return status is 0.  If there is a redirection  error,  the
              return status is 1.

Also:
https://forum.artixlinux.org/index.php/topic,1923.0.html
Quote
What to do if I have a problem:

First go through wiki.archlinux.org and wiki.artixlinux.org and use the relevant parts (all except the systemd commands on the archlinux wiki) to set up your system really correctly.

Look at the internet to see if anyone has had a similar error (at least 90% of problems have already been solved on the internet before you) - often a question of 5 minutes before solving it here for days and peoples here will look at the internet anyway :-)

Re: [runit] Pipewire crashes after suspend

Reply #5
Thanks for your hints and help. I read through the wiki entries and adjusted my .xinitrc accordingly:

Code: [Select]
$ cat .xinitrc 
pipewire &
pipewire-pulse &
pipewire-alsa &
wireplumber &
xrdb ~/.Xresources
exec dbus-launch startxfce4

Here is the rest of the information of my system:

Code: [Select]
$ lspci -v
00:00.0 Host bridge: Intel Corporation Xeon E3-1200 v6/7th Gen Core Processor Host Bridge/DRAM Registers (rev 08)
Subsystem: Lenovo Device 506c
Flags: bus master, fast devsel, latency 0
Capabilities: <access denied>
Kernel driver in use: skl_uncore

00:02.0 VGA compatible controller: Intel Corporation UHD Graphics 620 (rev 07) (prog-if 00 [VGA controller])
Subsystem: Lenovo Device 506c
Flags: bus master, fast devsel, latency 0, IRQ 139
Memory at e0000000 (64-bit, non-prefetchable) [size=16M]
Memory at c0000000 (64-bit, prefetchable) [size=512M]
I/O ports at e000 [size=64]
Expansion ROM at 000c0000 [virtual] [disabled] [size=128K]
Capabilities: <access denied>
Kernel driver in use: i915
Kernel modules: i915

00:04.0 Signal processing controller: Intel Corporation Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor Thermal Subsystem (rev 08)
Subsystem: Lenovo Device 506c
Flags: fast devsel, IRQ 16
Memory at e1340000 (64-bit, non-prefetchable) [size=32K]
Capabilities: <access denied>
Kernel driver in use: proc_thermal
Kernel modules: processor_thermal_device_pci_legacy

00:14.0 USB controller: Intel Corporation Sunrise Point-LP USB 3.0 xHCI Controller (rev 21) (prog-if 30 [XHCI])
Subsystem: Lenovo Device 506c
Flags: bus master, medium devsel, latency 0, IRQ 136
Memory at e1320000 (64-bit, non-prefetchable) [size=64K]
Capabilities: <access denied>
Kernel driver in use: xhci_hcd
Kernel modules: xhci_pci

00:14.2 Signal processing controller: Intel Corporation Sunrise Point-LP Thermal subsystem (rev 21)
Subsystem: Lenovo Device 506c
Flags: fast devsel, IRQ 18
Memory at e1350000 (64-bit, non-prefetchable) [size=4K]
Capabilities: <access denied>
Kernel driver in use: intel_pch_thermal
Kernel modules: intel_pch_thermal

00:15.0 Signal processing controller: Intel Corporation Sunrise Point-LP Serial IO I2C Controller #0 (rev 21)
Subsystem: Lenovo Device 506c
Flags: bus master, fast devsel, latency 0, IRQ 16
Memory at e1351000 (64-bit, non-prefetchable) [size=4K]
Capabilities: <access denied>
Kernel driver in use: intel-lpss
Kernel modules: intel_lpss_pci

00:15.1 Signal processing controller: Intel Corporation Sunrise Point-LP Serial IO I2C Controller #1 (rev 21)
Subsystem: Lenovo Device 506c
Flags: bus master, fast devsel, latency 0, IRQ 17
Memory at e1352000 (64-bit, non-prefetchable) [size=4K]
Capabilities: <access denied>
Kernel driver in use: intel-lpss
Kernel modules: intel_lpss_pci

00:16.0 Communication controller: Intel Corporation Sunrise Point-LP CSME HECI #1 (rev 21)
Subsystem: Lenovo Device 506c
Flags: bus master, fast devsel, latency 0, IRQ 126
Memory at e1353000 (64-bit, non-prefetchable) [size=4K]
Capabilities: <access denied>
Kernel driver in use: mei_me
Kernel modules: mei_me

00:1c.0 PCI bridge: Intel Corporation Sunrise Point-LP PCI Express Root Port #1 (rev f1) (prog-if 00 [Normal decode])
Flags: bus master, fast devsel, latency 0, IRQ 122
Bus: primary=00, secondary=01, subordinate=01, sec-latency=0
I/O behind bridge: [disabled]
Memory behind bridge: [disabled]
Prefetchable memory behind bridge: [disabled]
Capabilities: <access denied>
Kernel driver in use: pcieport

00:1c.2 PCI bridge: Intel Corporation Sunrise Point-LP PCI Express Root Port #3 (rev f1) (prog-if 00 [Normal decode])
Flags: bus master, fast devsel, latency 0, IRQ 123
Bus: primary=00, secondary=02, subordinate=02, sec-latency=0
I/O behind bridge: [disabled]
Memory behind bridge: e1200000-e12fffff [size=1M]
Prefetchable memory behind bridge: [disabled]
Capabilities: <access denied>
Kernel driver in use: pcieport

00:1c.4 PCI bridge: Intel Corporation Sunrise Point-LP PCI Express Root Port #5 (rev f1) (prog-if 00 [Normal decode])
Flags: bus master, fast devsel, latency 0, IRQ 124
Bus: primary=00, secondary=03, subordinate=03, sec-latency=0
I/O behind bridge: [disabled]
Memory behind bridge: e1100000-e11fffff [size=1M]
Prefetchable memory behind bridge: [disabled]
Capabilities: <access denied>
Kernel driver in use: pcieport

00:1d.0 PCI bridge: Intel Corporation Sunrise Point-LP PCI Express Root Port #9 (rev f1) (prog-if 00 [Normal decode])
Flags: bus master, fast devsel, latency 0, IRQ 125
Bus: primary=00, secondary=04, subordinate=04, sec-latency=0
I/O behind bridge: [disabled]
Memory behind bridge: e1000000-e10fffff [size=1M]
Prefetchable memory behind bridge: [disabled]
Capabilities: <access denied>
Kernel driver in use: pcieport

00:1f.0 ISA bridge: Intel Corporation Sunrise Point LPC Controller/eSPI Controller (rev 21)
Subsystem: Lenovo Device 506c
Flags: bus master, medium devsel, latency 0

00:1f.2 Memory controller: Intel Corporation Sunrise Point-LP PMC (rev 21)
Subsystem: Lenovo Device 506c
Flags: fast devsel
Memory at e134c000 (32-bit, non-prefetchable) [disabled] [size=16K]

00:1f.3 Audio device: Intel Corporation Sunrise Point-LP HD Audio (rev 21)
Subsystem: Lenovo Device 506c
Flags: bus master, fast devsel, latency 64, IRQ 140
Memory at e1348000 (64-bit, non-prefetchable) [size=16K]
Memory at e1330000 (64-bit, non-prefetchable) [size=64K]
Capabilities: <access denied>
Kernel driver in use: snd_hda_intel
Kernel modules: snd_hda_intel, snd_soc_skl

00:1f.4 SMBus: Intel Corporation Sunrise Point-LP SMBus (rev 21)
Subsystem: Lenovo Device 506c
Flags: medium devsel, IRQ 16
Memory at e1354000 (64-bit, non-prefetchable) [size=256]
I/O ports at efa0 [size=32]
Kernel driver in use: i801_smbus
Kernel modules: i2c_i801

00:1f.6 Ethernet controller: Intel Corporation Ethernet Connection (4) I219-V (rev 21)
Subsystem: Lenovo Device 506c
Flags: bus master, fast devsel, latency 0, IRQ 141
Memory at e1300000 (32-bit, non-prefetchable) [size=128K]
Capabilities: <access denied>
Kernel driver in use: e1000e
Kernel modules: e1000e

02:00.0 Network controller: Intel Corporation Wireless 8265 / 8275 (rev 78)
Subsystem: Intel Corporation Dual Band Wireless-AC 8265
Flags: bus master, fast devsel, latency 0, IRQ 138
Memory at e1200000 (64-bit, non-prefetchable) [size=8K]
Capabilities: <access denied>
Kernel driver in use: iwlwifi
Kernel modules: iwlwifi

03:00.0 Non-Volatile memory controller: Samsung Electronics Co Ltd NVMe SSD Controller SM961/PM961/SM963 (prog-if 02 [NVM Express])
Subsystem: Samsung Electronics Co Ltd SM963 2.5" NVMe PCIe SSD
Flags: bus master, fast devsel, latency 0, IRQ 16, NUMA node 0
Memory at e1100000 (64-bit, non-prefetchable) [size=16K]
Capabilities: <access denied>
Kernel driver in use: nvme

04:00.0 Unassigned class [ff00]: Realtek Semiconductor Co., Ltd. RTS522A PCI Express Card Reader (rev 01)
Subsystem: Lenovo Device 506c
Flags: bus master, fast devsel, latency 0, IRQ 135
Memory at e1000000 (32-bit, non-prefetchable) [size=4K]
Capabilities: <access denied>
Kernel driver in use: rtsx_pci
Kernel modules: rtsx_pci

Regarding dmesg:
dmesg log


Code: [Select]
$ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 005: ID 8087:0a2b Intel Corp. Bluetooth wireless interface
Bus 001 Device 004: ID 5986:2113 Acer, Inc SunplusIT Integrated Camera
Bus 001 Device 003: ID 046d:c084 Logitech, Inc. G203 Gaming Mouse
Bus 001 Device 002: ID 0416:0123 Winbond Electronics Corp. Ducky One2 SF RGB
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Code: [Select]
$ lsmod
Module                  Size  Used by
rfcomm                 90112  12
fuse                  176128  2
snd_seq_dummy          16384  0
snd_hrtimer            16384  0
snd_seq                90112  1 snd_seq_dummy
snd_seq_device         16384  1 snd_seq
ccm                    20480  9
nf_tables             274432  0
libcrc32c              16384  1 nf_tables
nfnetlink              20480  1 nf_tables
cmac                   16384  3
algif_hash             16384  1
algif_skcipher         16384  1
af_alg                 36864  6 algif_hash,algif_skcipher
bnep                   32768  2
vfat                   24576  1
fat                    90112  1 vfat
snd_hda_codec_hdmi     86016  1
snd_soc_skl           221184  0
snd_soc_hdac_hda       28672  1 snd_soc_skl
snd_hda_ext_core       36864  2 snd_soc_hdac_hda,snd_soc_skl
snd_soc_sst_ipc        20480  1 snd_soc_skl
snd_soc_sst_dsp        40960  1 snd_soc_skl
elan_i2c               73728  0
snd_ctl_led            24576  0
snd_soc_acpi_intel_match    57344  1 snd_soc_skl
intel_tcc_cooling      16384  0
snd_soc_acpi           16384  2 snd_soc_acpi_intel_match,snd_soc_skl
snd_hda_codec_realtek   159744  1
x86_pkg_temp_thermal    20480  0
intel_powerclamp       20480  0
snd_hda_codec_generic    98304  1 snd_hda_codec_realtek
coretemp               20480  0
snd_soc_core          393216  2 snd_soc_hdac_hda,snd_soc_skl
kvm_intel             356352  0
snd_compress           28672  1 snd_soc_core
ac97_bus               16384  1 snd_soc_core
btusb                  65536  0
uvcvideo              147456  0
kvm                  1097728  1 kvm_intel
videobuf2_vmalloc      20480  1 uvcvideo
videobuf2_memops       20480  1 videobuf2_vmalloc
snd_pcm_dmaengine      16384  1 snd_soc_core
btrtl                  28672  1 btusb
irqbypass              16384  1 kvm
videobuf2_v4l2         40960  1 uvcvideo
btbcm                  24576  1 btusb
snd_hda_intel          61440  0
crct10dif_pclmul       16384  1
btintel                45056  1 btusb
videobuf2_common       86016  4 videobuf2_vmalloc,videobuf2_v4l2,uvcvideo,videobuf2_memops
iTCO_wdt               16384  0
ee1004                 20480  0
crc32_pclmul           16384  0
intel_pmc_bxt          16384  1 iTCO_wdt
iTCO_vendor_support    16384  1 iTCO_wdt
ghash_clmulni_intel    16384  0
snd_intel_dspcfg       32768  2 snd_hda_intel,snd_soc_skl
bluetooth             749568  41 btrtl,btintel,btbcm,bnep,btusb,rfcomm
joydev                 28672  0
mousedev               24576  0
aesni_intel           380928  10
videodev              307200  3 videobuf2_v4l2,uvcvideo,videobuf2_common
snd_intel_sdw_acpi     20480  1 snd_intel_dspcfg
iwlmvm                503808  0
crypto_simd            16384  1 aesni_intel
snd_hda_codec         184320  5 snd_hda_codec_generic,snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec_realtek,snd_soc_hdac_hda
think_lmi              28672  0
cryptd                 28672  3 crypto_simd,ghash_clmulni_intel
mei_hdcp               24576  0
ecdh_generic           16384  2 bluetooth
intel_rapl_msr         20480  0
mc                     65536  4 videodev,videobuf2_v4l2,uvcvideo,videobuf2_common
wmi_bmof               16384  0
firmware_attributes_class    16384  1 think_lmi
intel_wmi_thunderbolt    20480  0
rapl                   16384  0
snd_hda_core          118784  8 snd_hda_codec_generic,snd_hda_codec_hdmi,snd_hda_intel,snd_hda_ext_core,snd_hda_codec,snd_hda_codec_realtek,snd_soc_hdac_hda,snd_soc_skl
intel_cstate           20480  0
snd_hwdep              16384  1 snd_hda_codec
mac80211             1236992  1 iwlmvm
intel_uncore          208896  0
libarc4                16384  1 mac80211
snd_pcm               163840  8 snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec,snd_compress,snd_soc_core,snd_soc_skl,snd_hda_core,snd_pcm_dmaengine
processor_thermal_device_pci_legacy    16384  0
i2c_i801               45056  0
psmouse               212992  0
pcspkr                 16384  0
e1000e                331776  0
i2c_smbus              20480  1 i2c_i801
snd_timer              49152  3 snd_seq,snd_hrtimer,snd_pcm
tpm_crb                20480  0
iwlwifi               458752  1 iwlmvm
processor_thermal_device    20480  1 processor_thermal_device_pci_legacy
processor_thermal_rfim    16384  1 processor_thermal_device
i915                 3276800  13
tpm_tis                16384  0
usbhid                 73728  0
ucsi_acpi              16384  0
processor_thermal_mbox    16384  2 processor_thermal_rfim,processor_thermal_device
thinkpad_acpi         172032  0
intel_lpss_pci         28672  0
mei_me                 53248  1
processor_thermal_rapl    20480  1 processor_thermal_device
cfg80211             1073152  3 iwlmvm,iwlwifi,mac80211
intel_lpss             16384  1 intel_lpss_pci
tpm_tis_core           32768  1 tpm_tis
mei                   167936  3 mei_hdcp,mei_me
typec_ucsi             53248  1 ucsi_acpi
intel_pch_thermal      20480  0
idma64                 20480  0
ledtrig_audio          16384  3 snd_ctl_led,snd_hda_codec_generic,thinkpad_acpi
intel_rapl_common      32768  2 intel_rapl_msr,processor_thermal_rapl
ttm                    86016  1 i915
tpm                    98304  3 tpm_tis,tpm_crb,tpm_tis_core
typec                  65536  1 typec_ucsi
platform_profile       16384  1 thinkpad_acpi
intel_xhci_usb_role_switch    16384  0
intel_soc_dts_iosf     20480  1 processor_thermal_device_pci_legacy
intel_gtt              28672  1 i915
roles                  16384  2 typec_ucsi,intel_xhci_usb_role_switch
rng_core               16384  1 tpm
wmi                    45056  3 intel_wmi_thunderbolt,wmi_bmof,think_lmi
rfkill                 32768  8 bluetooth,thinkpad_acpi,cfg80211
i2c_hid_acpi           16384  0
snd                   126976  14 snd_ctl_led,snd_hda_codec_generic,snd_seq,snd_seq_device,snd_hda_codec_hdmi,snd_hwdep,snd_hda_intel,snd_hda_codec,snd_hda_codec_realtek,snd_timer,snd_compress,thinkpad_acpi,snd_soc_core,snd_pcm
i2c_hid                40960  1 i2c_hid_acpi
int3403_thermal        20480  0
soundcore              16384  2 snd_ctl_led,snd
crypto_user            24576  0
soc_button_array       20480  0
int340x_thermal_zone    20480  2 int3403_thermal,processor_thermal_device
video                  57344  2 thinkpad_acpi,i915
acpi_pad               24576  0
int3400_thermal        20480  0
mac_hid                16384  0
acpi_thermal_rel       16384  1 int3400_thermal
ext4                 1003520  1
crc32c_generic         16384  0
crc16                  16384  2 bluetooth,ext4
mbcache                16384  1 ext4
jbd2                  192512  1 ext4
rtsx_pci_sdmmc         32768  0
serio_raw              20480  0
atkbd                  36864  0
mmc_core              225280  1 rtsx_pci_sdmmc
libps2                 20480  2 atkbd,psmouse
crc32c_intel           24576  3
i8042                  40960  0
xhci_pci               20480  0
rtsx_pci              110592  1 rtsx_pci_sdmmc
xhci_pci_renesas       24576  1 xhci_pci
serio                  28672  6 serio_raw,atkbd,psmouse,i8042

I read through man 1 loginctl, especially the "Hook directories" part and as far as I understand it, I have to place executables of pipewire and its components to /usr/lib/elogind/system-sleep in order for elogind to manage these programs when suspending my system. Am I right?

Re: [runit] Pipewire crashes after suspend

Reply #6
I read through man 1 loginctl, especially the "Hook directories" part and as far as I understand it, I have to place executables of pipewire and its components to /usr/lib/elogind/system-sleep in order for elogind to manage these programs when suspending my system. Am I right?

Quote
   Hook directories
       [/usr]/lib[64]/elogind/system-sleep/, /etc/elogind/system-sleep/
           Immediately before entering system suspend and/or hibernation elogind will run all executables in
           [/usr]/lib[64]/elogind/system-sleep/ and /etc/elogind/system-sleep/ and pass two arguments to them. The first argument will be
           "pre", the second either "suspend", "hibernate", "hybrid-sleep", or "suspend-then-hibernate", depending on the chosen action.
           Immediately after leaving system suspend and/or hibernation the same executables are run, but the first argument is now "post".

           All executables in this directory are executed sequentially, and execution of the action is not continued until all executables
           have finished.

Not directly pipewire executable, as it doesn't parse the arguments sent by elogind. Rather, something like the script given as an example here:
https://wiki.archlinux.org/title/Power_management#Hooks_in_/usr/lib/systemd/system-sleep

 

Re: [runit] Pipewire crashes after suspend

Reply #7
Thanks for the hints
Now I understand what elogind actually does in this case and why it is handy to use a shell script to parse the arguments and use them in order to tell the system what to do before (pre) and after (post) suspend etc.
As the noob I am, I'm tempted to killall pipewire and wireplumber processes post suspend and restart them again. But this doesn't seem to be an elegant solution at all. There would also be the problem of waiting for the processes to shutdown properly before starting them again. Would there be a more gentle way to solve this?

Re: [runit] Pipewire crashes after suspend

Reply #8
But this doesn't seem to be an elegant solution at all.
Why not? That's how daemons and processes in general are managed, unless they include a different method. Pipewire doesn't.

Code: [Select]
man kill
Quote
       If no signal is specified, the TERM signal is sent. The default action for this signal is to terminate the process. This signal should be used in preference to the KILL signal
       (number 9), since a process may install a handler for the TERM signal in order to perform clean-up steps before terminating in an orderly fashion. If a process does not terminate
       after a TERM signal has been sent, then the KILL signal may be used; be aware that the latter signal cannot be caught, and so does not give the target process the opportunity to
       perform any clean-up before terminating.

Also see:
Code: [Select]
man 7 signal
man wait
man pidof

Re: [runit] Pipewire crashes after suspend

Reply #9
All right, thanks for the hints!

This is what my sleep script now looks like:
Code: [Select]
$ cat /usr/lib/elogind/system-sleep/00-pipewire.sh 
#!/bin/sh

pid_pipewire=$(pidof pipewire)
pid_pipe_pulse=$(pidof pipewire-pulse)
pid_wireplumber=$(pidof wireplumber)

case $1/$2 in
  pre/*)
    ;;
  post/*)
    kill $pid_wireplumber
    wait $pid_wireplumber
    kill $pid_pipe_pulse
    wait $pid_pipe_pulse
    kill $pid_pipewire
    wait $pid_pipewire

    pipewire &
    pipewire-pulse &
    wireplumber &
    ;;
esac

Any objections to that? :)

Re: [runit] Pipewire crashes after suspend

Reply #10
wait is unnecessary here, as all those programs are well behaved. It is enough to just issue kill command, and, since it accepts multiple arguments, just one kill command is enough:
Code: [Select]
kill $(pidof pipewire) $(pidof pipewire-pulse) $(pidof wireplumber)
Of course, you could refine (or complicate) this further by checking if the processes terminated and giving a timeout, after which SIGKILL is sent, but in my opinion it is unnecessary.

Re: [runit] Pipewire crashes after suspend

Reply #11
Thanks again for your input, @strajder !

I've adjusted my script according to your explanation, restarted the system and tried it out by closing and opening my laptop lid. Unfortunately, it still does not work. But now it seems that the pipewire processes get killed as intended but the part of the script where they should be started again does not. I can now manually start them without any errors, though.

Maybe this is because the script tells them to start pipewire etc again even though the old processes might not be shutdown correctly yet?


Re: [runit] Pipewire crashes after suspend

Reply #13
The problem still persists, unfortunately. This is how my script looks like right now:

Code: [Select]
$ cat /usr/lib/elogind/system-sleep/00-pipewire.sh
#!/bin/sh
case $1/$2 in
  pre/*)
    kill $(pidof pipewire) $(pidof pipewire-pulse) $(pidof wireplumber)
    ;;
  post/*)
    pipewire &
    pipewire-pulse &
    wireplumber &
    ;;
esac