summary refs log tree commit diff
path: root/doc/libs6/s6-ftrigrd.html
blob: baa3b661d226d13dfe74f4afe1140f9e51dd4393 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta http-equiv="Content-Language" content="en" />
    <title>s6: the s6-ftrigrd program</title>
    <meta name="Description" content="s6: the s6-ftrigrd program" />
    <meta name="Keywords" content="s6 command s6-ftrigrd program internal libexec fifodir regexp subscribe notification listener" />
    <!-- <link rel="stylesheet" type="text/css" href="//skarnet.org/default.css" /> -->
  </head>
<body>

<p>
<a href="index.html">libs6</a><br />
<a href="../">s6</a><br />
<a href="//skarnet.org/software/">Software</a><br />
<a href="//skarnet.org/">skarnet.org</a>
</p>

<h1> The s6-ftrigrd program </h1>

<p>
s6-ftrigrd is a helper program that manages a set of subscriptions to fifodirs as well
as regular expressions on events. It takes orders from its client program that controls
it via the <a href="ftrigr.html">ftrigr library</a>, and notifies it when desired
events happen.
</p>

<h2> Interface </h2>

<p>
 s6-ftrigrd is not meant to be called directly.
</p>

<ul>
 <li> If the client program uses <tt>ftrigr_startf()</tt>, it spawns an instance of
s6-ftrigrd as a child. s6-ftrigrd's stdin is a pipe reading from the client; its
stdout is a pipe writing to the client; its stderr is the same as the client's; and
there's an additional pipe from s6-ftrigrd to the client, used for asynchronous
notifications. </li>
 <li> If the client program uses <tt>ftrigr_start()</tt>, then it tries to connect
to a Unix domain socket. A ftrigrd <a href="../localservice.html">local service</a> should be listening to that
socket, i.e. a Unix domain superserver such as
<a href="s6-ipcserver.html">s6-ipcserver</a>
spawning a s6-ftrigrd program on every connection. Then a s6-ftrigrd instance is created
for the client. </li>
 <li> When the client uses <tt>ftrigr_end()</tt>, or closes s6-ftrigrd's stdin in
any way, s6-ftrigrd exits 0. </li>
</ul>

<p>
 s6-ftrigrd handles the grunt work of creating fifos in a
<a href="../fifodir.html">fifodir</a> for a subscriber. It also wakes up on every
event, and compares the chain of events it received on a given fifodir with the
client-provided regexp. If the chain of events matches the regexp, it notifies
the client.
</p>

<h2> Notes </h2>

<p>
 The connection management between the client and s6-ftrigrd is entirely done
by the <a href="//skarnet.org/software/skalibs/libunixonacid/skaclient.html">skaclient</a>
library.
</p>

<p>
 s6-ftrigrd is entirely asynchronous. It stores unread notifications into heap
memory; it can grow in size if there are a lot of events and the client fails
to read them. To avoid uncontrolled growth, make sure your client calls
<tt>ftrigr_update()</tt> as soon as <tt>ftrigr_fd()</tt> becomes readable.
</p>

<p>
 A s6-ftrigrd instance can only handle up to FTRIGRD_MAX (defined in <tt>s6/ftrigr.h</tt>)
subscriptions at once. By default, this number is 1000, which is more than enough for
any reasonable system.
</p>

</body>
</html>