Score:0

Using pkill or kill ps aux (inside a script) to kill processes results in Pulseaudio losing audio connection?

sg flag

I have this script that searches for multiple applications and kills them for situations of low memory (or when browser starts to lag CPU)

pkill -f 'chrome --type=renderer' (Kills only browser tabs, not entire browser)  
pkill -f 'firefox'  
pkill -f 'ffmpeg'  
pkill -f 'Portion_Of_Your_App_Name_Here'  

Activated by a hotkey.

When using said commands individually from a terminal, processes get killed and pulseaudio continues working (other applications continue playing audio normally)

It's only when I use the SCRIPT itself that Pulseaudio seems to be killed too?
edit: Which also results in OBS-Studio losing audio connection

Is there a workaround for this?
pkill or kill -9 'ps aux | grep' results in same behavior

using the "time" command yields these results:  
time pkill -f 'string portion of process name'
time to run= 0.018s
\n  
time script.sh (SCRIPT RUNS)  
time to run= 0.262s (much higher execution time... syntax problem?)  

It's also curious to notice that killall command takes only 0.006s to run instead of 0.018s of pkill or pgrep
Also notice this issue did not happen in previous distro version (older pulseaudio version 16.04 distro, which had other issues but not this one specifically)

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.