[pulseaudio-discuss] pactl subscribe: immune to SIGPIPE
Nikita Zlobin
cook60020tmp at mail.ru
Thu Dec 24 12:43:46 UTC 2020
I tried "pactl subscribe" as even source for volume indicator, written
as shell script.
For minimal test I used this:
$ LANG=C pactl subscribe | stdbuf -oL awk '/change/ { print; exit }'
Full pipeline (simplified to show the issue):
$ env LANG=C pactl subscribe \
| stdbuf -oL awk '$2 == "'"'change'"'" { print "list-sinks" }' \
| "pacmd" \
| stdbuf -oL awk '
BEGIN {
parse_stage = 0
sink_id = -1
}
/^sink / { sink_id = $2; next }
# actual parsing for volume and mute
' |
{ ### adapter code ### } &
pid=$!
pulsemixer
kill $!
Ideally pipeline was to terminate by SIGPIPE chain from
terminated adapter sibling.
As workaround I wrap all pipeline to parenthesis with ampersand left
outside and use job control (doing "set -m" before pipeline start) to
kill all process group with "kill -- -$pid".
Well, to be fair, I have more reason for this workaround after trying
to pass controlled sink ID between two awks by making "pacmd"
controlled by first awk:
awk '{ print $5; print "list-sinks" | "pacmd" }' | awk .....
More information about the pulseaudio-discuss
mailing list