aboutsummaryrefslogtreecommitdiffstats
path: root/reapd.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2017-10-17 18:24:03 +0200
committerMattias Andrée <maandree@kth.se>2017-10-17 18:24:03 +0200
commit9eb16aa2cdcdf14642ef43e5498a8f626a72d99c (patch)
tree0fb5b58f2767674f3038f759d803822e0c780fe2 /reapd.c
parentupdate dist (diff)
downloadorphan-reaper-2.3.tar.gz
orphan-reaper-2.3.tar.bz2
orphan-reaper-2.3.tar.xz
Rewrite and relicense2.3
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'reapd.c')
-rw-r--r--reapd.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/reapd.c b/reapd.c
new file mode 100644
index 0000000..c3ba452
--- /dev/null
+++ b/reapd.c
@@ -0,0 +1,27 @@
+/* See LICENSE file for copyright and license details. */
+#include <sys/wait.h>
+#include <errno.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <string.h>
+
+
+int
+main(int argc, char *argv[])
+{
+ for (;;) {
+ if (wait(NULL) == -1) {
+ if (errno == ECHILD)
+ return 0;
+ if (errno == EINTR)
+ continue;
+ fprintf(stderr, "%s: wait: %s\n", *argv, strerror(errno));
+ return 2;
+ }
+#ifdef TEST
+ printf("reaped\n");
+#endif
+ }
+
+ (void) argc;
+}