]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/sd_event_add_child.xml
man: revert dynamic paths for split-usr setups
[thirdparty/systemd.git] / man / sd_event_add_child.xml
CommitLineData
3802a3d3 1<?xml version='1.0'?> <!--*- Mode: nxml; nxml-child-indent: 2; indent-tabs-mode: nil -*-->
edf25737 2<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
12b42c76 3"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
edf25737
ZJS
4
5<!--
5de0ccff 6 This file is part of systemd.
edf25737 7
5de0ccff 8 Copyright 2014 Zbigniew Jędrzejewski-Szmek
edf25737 9
5de0ccff
ZJS
10 systemd is free software; you can redistribute it and/or modify it
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
edf25737 14
5de0ccff
ZJS
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
edf25737 19
5de0ccff
ZJS
20 You should have received a copy of the GNU Lesser General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
edf25737
ZJS
22-->
23
48f69d8f 24<refentry id="sd_event_add_child">
edf25737
ZJS
25
26 <refentryinfo>
27 <title>sd_event_add_child</title>
28 <productname>systemd</productname>
29
30 <authorgroup>
31 <author>
32 <contrib>More text</contrib>
33 <firstname>Zbigniew</firstname>
34 <surname>Jędrzejewski-Szmek</surname>
35 <email>zbyszek@in.waw.pl</email>
36 </author>
37 </authorgroup>
38 </refentryinfo>
39
40 <refmeta>
41 <refentrytitle>sd_event_add_child</refentrytitle>
42 <manvolnum>3</manvolnum>
43 </refmeta>
44
45 <refnamediv>
46 <refname>sd_event_add_child</refname>
47 <refname>sd_event_source_get_child_pid</refname>
48
49 <refpurpose>Add a child state change event source to an event loop</refpurpose>
50 </refnamediv>
51
52 <refsynopsisdiv>
53 <funcsynopsis>
54 <funcsynopsisinfo>#include &lt;systemd/sd-bus.h&gt;</funcsynopsisinfo>
55
56 <funcprototype>
57 <funcdef>int <function>sd_event_add_child</function></funcdef>
58 <paramdef>sd_event *<parameter>event</parameter></paramdef>
59 <paramdef>sd_event_source **<parameter>source</parameter></paramdef>
60 <paramdef>pid_t <parameter>pid</parameter></paramdef>
61 <paramdef>int <parameter>options</parameter></paramdef>
62 <paramdef>sd_event_child_handler_t <parameter>handler</parameter></paramdef>
63 <paramdef>void *<parameter>userdata</parameter></paramdef>
64 </funcprototype>
65
66 <funcprototype>
67 <funcdef>typedef int (*<function>sd_event_child_handler_t</function>)</funcdef>
68 <paramdef>sd_event_source *<parameter>s</parameter></paramdef>
69 <paramdef>const siginfo_t *<parameter>si</parameter></paramdef>
70 <paramdef>void *<parameter>userdata</parameter></paramdef>
71 </funcprototype>
72
73 <funcprototype>
74 <funcdef>int <function>sd_event_source_get_child_pid</function></funcdef>
75 <paramdef>sd_event_source *<parameter>source</parameter></paramdef>
76 <paramdef>pid_t *<parameter>pid</parameter></paramdef>
77 </funcprototype>
78
79 </funcsynopsis>
80 </refsynopsisdiv>
81
82 <refsect1>
83 <title>Description</title>
84
85 <para><function>sd_event_add_child()</function> adds a new child
86 state change event source to an event loop object. The event loop
87 is specified in <parameter>event</parameter>, the event source is
88 returned in the <parameter>source</parameter> parameter. The
89 <parameter>pid</parameter> parameter specifies the process to
90 watch. The <parameter>handler</parameter> must reference a
91 function to call when the process changes state. The handler
92 function will be passed the <parameter>userdata</parameter>
93 pointer, which may be chosen freely by the caller. The handler
94 also receives a pointer to a <structname>const
95 siginfo_t</structname> structure containing the information about
96 the event. The <parameter>options</parameter> parameter determines
97 which state changes will be watched for. It must contain an OR-ed
98 mask of <constant>WEXITED</constant> (watch for the child
99 terminating), <constant>WSTOPPED</constant> (watch for the child
100 being stopped by a signal), and <constant>WCONTINUED</constant>
101 (watch for the child being resumed by a signal). See
102 <citerefentry><refentrytitle>waitid</refentrytitle><manvolnum>2</manvolnum></citerefentry>
922d948b 103 for further information.</para>
edf25737
ZJS
104
105 <para>Only a single handler may be installed for a specific
106 child. The handler is enabled
107 for a single event (<constant>SD_EVENT_ONESHOT</constant>),
108 but this may be
109 changed with
110 <citerefentry><refentrytitle>sd_event_source_set_enabled</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
111 If the handler function returns a negative error code, it will be
112 disabled after the invocation, even if
113 <constant>SD_EVENT_ON</constant> mode is set.
114 </para>
115
116 <para><function>sd_event_source_get_child_pid()</function>
117 retrieves the configured <parameter>pid</parameter> of a child
118 state change event source created previously with
119 <function>sd_event_add_child()</function>. It takes the event
120 source object as the <parameter>source</parameter> parameter and a
121 pointer to <type>pid_t</type> to return the result in.
122 </para>
123 </refsect1>
124
125 <refsect1>
126 <title>Return Value</title>
127
128 <para>On success, these functions return 0 or a positive
129 integer. On failure, they return a negative errno-style error
130 code.</para>
131 </refsect1>
132
133 <refsect1>
134 <title>Errors</title>
135
136 <para>Returned errors may indicate the following problems:</para>
137
138 <variablelist>
139 <varlistentry>
8474b70c 140 <term><constant>-ENOMEM</constant></term>
edf25737
ZJS
141
142 <listitem><para>Not enough memory to allocate an object.</para></listitem>
143 </varlistentry>
144
145 <varlistentry>
8474b70c 146 <term><constant>-EINVAL</constant></term>
edf25737
ZJS
147
148 <listitem><para>An invalid argument has been passed. This includes
cc98b302 149 specifying an empty mask in <parameter>options</parameter> or a mask
f131770b 150 which contains values different than a combination of
edf25737
ZJS
151 <constant>WEXITED</constant>, <constant>WSTOPPED</constant>, and
152 <constant>WCONTINUED</constant>.
153 </para></listitem>
154
155 </varlistentry>
156
157 <varlistentry>
8474b70c 158 <term><constant>-EBUSY</constant></term>
edf25737
ZJS
159
160 <listitem><para>An handler is already installed for this
161 child.</para></listitem>
162
163 </varlistentry>
164
165 <varlistentry>
8474b70c 166 <term><constant>-ESTALE</constant></term>
edf25737
ZJS
167
168 <listitem><para>The event loop is already terminated.</para></listitem>
169
170 </varlistentry>
171
172 <varlistentry>
8474b70c 173 <term><constant>-ECHILD</constant></term>
edf25737
ZJS
174
175 <listitem><para>The event loop has been created in a different process.</para></listitem>
176
177 </varlistentry>
178
179 </variablelist>
180 </refsect1>
181
182 <refsect1>
183 <title>Notes</title>
184
185 <para><function>sd_event_add_child()</function> and the other functions
186 described here are available as a shared library, which can be
187 compiled and linked to with the
188 <constant>libsystemd</constant> <citerefentry project='die-net'><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
189 file.</para>
190 </refsect1>
191
192 <refsect1>
193 <title>See Also</title>
194
195 <para>
196 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
197 <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
198 <citerefentry><refentrytitle>sd_event_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
199 <citerefentry><refentrytitle>sd_event_add_time</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
200 <citerefentry><refentrytitle>sd_event_add_signal</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
4dfefc19 201 <citerefentry><refentrytitle>sd_event_add_defer</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
edf25737
ZJS
202 <citerefentry><refentrytitle>sd_event_source_set_enabled</refentrytitle><manvolnum>3</manvolnum></citerefentry>
203 </para>
204 </refsect1>
205
206</refentry>