s6
Software
skarnet.org

The s6-ftrig-listen1 program

s6-ftrig-listen1 subscribes to a fifodir, then spawns a program, then waits for a pattern of events to occur on the fifodir.

s6-ftrig-listen1 acts just as s6-ftrig-wait, except it can make sure that the process sending the notifications is actually started after there is a listener for those events.

Interface

     s6-ftrig-listen1 [ -t timeout ] fifodir regexp prog...

Options

Usage example

The following sequence of shell commands has a race condition:

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 process starts sending "message" before the s6-ftrig-wait 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