2 .TH "SD_EVENT_ADD_CHILD" "3" "" "systemd 217" "sd_event_add_child"
3 .\" -----------------------------------------------------------------
4 .\" * Define some portability stuff
5 .\" -----------------------------------------------------------------
6 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 .\" http://bugs.debian.org/507673
8 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
9 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12 .\" -----------------------------------------------------------------
13 .\" * set default formatting
14 .\" -----------------------------------------------------------------
15 .\" disable hyphenation
17 .\" disable justification (adjust text to left margin only)
19 .\" -----------------------------------------------------------------
20 .\" * MAIN CONTENT STARTS HERE *
21 .\" -----------------------------------------------------------------
23 sd_event_add_child, sd_event_source_get_child_pid \- Add a child state change event source to an event loop
28 #include <systemd/sd\-bus\&.h>
31 .HP \w'int\ sd_event_add_child('u
32 .BI "int sd_event_add_child(sd_event\ *" "event" ", sd_event_source\ **" "source" ", pid_t\ " "pid" ", int\ " "options" ", sd_event_child_handler_t\ " "handler" ", void\ *" "userdata" ");"
33 .HP \w'typedef\ int\ (*sd_event_child_handler_t)('u
34 .BI "typedef int (*sd_event_child_handler_t)(sd_event_source\ *" "s" ", const\ siginfo_t\ *" "si" ", void\ *" "userdata" ");"
35 .HP \w'int\ sd_event_source_get_child_pid('u
36 .BI "int sd_event_source_get_child_pid(sd_event_source\ *" "source" ", pid_t\ *" "pid" ");"
39 \fBsd_event_add_child()\fR
40 adds a new child state change event source to an event loop object\&. The event loop is specified in
41 \fIevent\fR, the event source is returned in the
45 parameter specifies the process to watch\&. The
47 must reference a function to call when the process changes state\&. The handler function will be passed the
49 pointer, which may be chosen freely by the caller\&. The handler also receives a pointer to a
51 structure containing the information about the event\&. The
53 parameter determines which state changes will be watched for\&. It must contain an OR\-ed mask of
55 (watch for the child terminating),
57 (watch for the child being stopped by a signal), and
59 (watch for the child being resumed by a signal)\&. See
61 for futher information\&.
63 Only a single handler may be installed for a specific child\&. The handler is enabled for a single event (\fBSD_EVENT_ONESHOT\fR), but this may be changed with
64 \fBsd_event_source_set_enabled\fR(3)\&. If the handler function returns a negative error code, it will be disabled after the invocation, even if
68 \fBsd_event_source_get_child_pid()\fR
69 retrieves the configured
71 of a child state change event source created previously with
72 \fBsd_event_add_child()\fR\&. It takes the event source object as the
74 parameter and a pointer to
76 to return the result in\&.
79 On success, these functions return 0 or a positive integer\&. On failure, they return a negative errno\-style error code\&.
82 Returned errors may indicate the following problems:
86 Not enough memory to allocate an object\&.
91 An invalid argument has been passed\&. This includes specyfing an empty mask in
93 or a mask which constains values different than a combination of
101 An handler is already installed for this child\&.
106 The event loop is already terminated\&.
111 The event loop has been created in a different process\&.
115 \fBsd_event_add_child()\fR
116 and the other functions described here are available as a shared library, which can be compiled and linked to with the
117 \fBlibsystemd\fR\ \&\fBpkg-config\fR(1)
123 \fBsd_event_new\fR(3),
124 \fBsd_event_add_time\fR(3),
125 \fBsd_event_add_signal\fR(3),
126 \fBsd_event_add_defer\fR(3),
127 \fBsd_event_source_set_enabled\fR(3)