S6-FTRIG-LISTEN1(8)
π s6-ftrig-listen1(8) β System Manager's Manual vibes π
okay so bestie, this is the s6-ftrig-listen1(8) page from the System Manager's Manual, and it's honestly kind of iconic: it subscribes first, then spawns the program, so the notification can't ghost you before you're listening. π
πΈ NAME πΈ
s6-ftrig-listen1 β subscribe to an s6-fifodir(7), then spawn a program, waiting for a pattern of events to occur on the fifodir.
β¨ SYNOPSIS β¨
s6-ftrig-listen1 [-t timeout] fifodir regexp prog...
π¦ DESCRIPTION π¦
So <pink>s6-ftrig-listen1</pink> does the same thing as s6-ftrig-wait(8), with one major main-character upgrade: it can make sure the process that's sending the notifications is actually started after there's already a listener for those events. No missed-connection energy. π
s6-ftrig-listen1 subscribes to fifodir.
Then it forks and execs prog... with all its arguments.
After that, it waits for the series of events received on fifodir to match regexp. And regexp must be an Extended Regular Expression[1] β that's the [1] link down in SEE ALSO, bestie. π«Ά
When the series of read events matches regexp, s6-ftrig-listen1 prints the last event it received to stdout (one byte followed by a newline), then exits 0. Slay. β¨
π OPTIONS π
-t timeoutβ if the events onfifodirhave not matchedregexpaftertimeoutmilliseconds, print an error message on stderr and exit1. By default,s6-ftrig-listen1waits indefinitely for a matching series of events.
π EXAMPLES π
The following sequence of shell commands has a race condition. π Not cute of the scheduler, honestly.
In terminal 1:
s6-mkfifodir /tmp/toto
s6-ftrig-wait /tmp/toto "message"
Then in terminal 2:
s6-ftrig-notify /tmp/toto message
Depending on the operating system's scheduler, there is the possibility that the s6-ftrig-notify(8) process starts sending βmessageβ before the s6-ftrig-wait(8) process has actually subscribed to /tmp/toto, in which case the notification will be missed. π
The following sequence of shell commands accomplishes the same goal in a reliable way, without the race condition:
s6-mkfifodir /tmp/toto
s6-ftrig-listen1 /tmp/toto "message" s6-ftrig-notify /tmp/toto message
See? Listener first, notification second. Order matters, periodt. π
π SEE ALSO π
s6-cleanfifodir(8)s6-ftrig-listen(8)s6-ftrig-notify(8)s6-ftrig-wait(8)s6-ftrigrd(8)s6-mkfifodir(8)[1]β the Extended Regular Expression reference:https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/V1_chap09.html#tag_09_04- This man page is ported from the authoritative documentation at:
https://skarnet.org/software/s6/s6-ftrig-listen1.html
π AUTHORS π
- Laurent Bercot
- Alexis
<flexibeast@gmail.com>(man page port)
signing off with the footer vibes: this is from Debian, dated September 29, 2021, for S6-FTRIG-LISTEN1(8) π
β¨
π¦ where this page comes from
- nixpkgs unstable: s6 2.15.1.0
- nixpkgs unstable: s6-man-pages 2.14.0.1.4
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms