S6-FTRIG-LISTEN1(8)

NAME
s6-ftrig-listen1 - subscribe to a fifodir, 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
s6-ftrig-listen1 acts just as s6-ftrig-wait(8), except it can make sure that the process sending the notifications is actually started after there is a listener for those events.

s6-ftrig-listen1 subscribes to fifodir.

It then forks and execs prog... with all its arguments.

It waits for the series of events received on fifodir to match regexp. regexp must be an Extended Regular Expression[1].

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.

OPTIONS

-t timeout
    If the events on fifodir have not matched regexp after timeout milliseconds, print an error message on stderr and exit 1. By default, s6-ftrig-listen1 waits indefinitely for a matching series of events.

EXAMPLES
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(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 ALSO
s6-cleanfifodir(8), s6-ftrig-listen(8), s6-ftrig-notify(8), s6-ftrig-wait(8), s6-ftrigrd(8), s6-mkfifodir(8)

[1] 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)