aboutsummaryrefslogtreecommitdiff
path: root/reaper.h
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-12-26 00:26:54 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-12-26 00:26:54 +0000
commit3c6789fb8ba87810a2aa83eebf6eea10c969db6d (patch)
tree72dddce6a55af8cc25ac7dfd016008ccd7d8eb94 /reaper.h
parentreadme: add builds.sr.ht status badge (diff)
reaper: add optional callback
When calling ‘reaper_add()’, the caller can provide a callback. If non-NULL, the reaper will call the callback to handle the actual reaping. If the callback is NULL, or if it returns false, the reaper reaps the child process.
Diffstat (limited to 'reaper.h')
-rw-r--r--reaper.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/reaper.h b/reaper.h
index 2daa9a8b..f955aa44 100644
--- a/reaper.h
+++ b/reaper.h
@@ -1,5 +1,6 @@
#pragma once
+#include <stdbool.h>
#include <sys/wait.h>
#include "fdm.h"
@@ -9,4 +10,6 @@ struct reaper;
struct reaper *reaper_init(struct fdm *fdm);
void reaper_destroy(struct reaper *reaper);
-void reaper_add(struct reaper *reaper, pid_t pid);
+typedef bool (*reaper_cb)(struct reaper *reaper, pid_t pid, void *data);
+
+void reaper_add(struct reaper *reaper, pid_t pid, reaper_cb cb, void *cb_data);