summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-10-11 01:33:25 +0200
committerLennart Poettering <lennart@poettering.net>2013-10-11 01:33:25 +0200
commit4bee801296daef257c64647353a1815d46fe2a34 (patch)
tree87d21c74816c467cdded641c4cf994c54ed23f91
parentbaf762833224267ef5380fb83b22f294628695a8 (diff)
event: add sd_event_source_get_child_pid() call to query the PID of a child event source
-rw-r--r--src/libsystemd-bus/sd-event.c10
-rw-r--r--src/systemd/sd-event.h3
2 files changed, 11 insertions, 2 deletions
diff --git a/src/libsystemd-bus/sd-event.c b/src/libsystemd-bus/sd-event.c
index 3094d9e297..482e3bb8a5 100644
--- a/src/libsystemd-bus/sd-event.c
+++ b/src/libsystemd-bus/sd-event.c
@@ -1297,6 +1297,16 @@ int sd_event_source_get_time_accuracy(sd_event_source *s, uint64_t *usec) {
return 0;
}
+int sd_event_source_get_child_pid(sd_event_source *s, pid_t *pid) {
+ assert_return(s, -EINVAL);
+ assert_return(pid, -EINVAL);
+ assert_return(s->type == SOURCE_CHILD, -EDOM);
+ assert_return(!event_pid_changed(s->event), -ECHILD);
+
+ *pid = s->child.pid;
+ return 0;
+}
+
int sd_event_source_set_prepare(sd_event_source *s, sd_prepare_handler_t callback) {
int r;
diff --git a/src/systemd/sd-event.h b/src/systemd/sd-event.h
index 1fd5648636..6ff85addb1 100644
--- a/src/systemd/sd-event.h
+++ b/src/systemd/sd-event.h
@@ -35,8 +35,6 @@
- Scales better with a large number of time events, since it doesn't require one timerfd each
- Automatically tries to coalesce timer events system-wide
- Handles signals and child PIDs
-
- TODO: rename mute to enable?
*/
typedef struct sd_event sd_event;
@@ -101,6 +99,7 @@ int sd_event_source_get_time(sd_event_source *s, uint64_t *usec);
int sd_event_source_set_time(sd_event_source *s, uint64_t usec);
int sd_event_source_set_time_accuracy(sd_event_source *s, uint64_t usec);
int sd_event_source_get_time_accuracy(sd_event_source *s, uint64_t *usec);
+int sd_event_source_get_child_pid(sd_event_source *s, pid_t *pid);
int sd_event_source_set_prepare(sd_event_source *s, sd_prepare_handler_t callback);
void* sd_event_source_get_userdata(sd_event_source *s);