--- /dev/null
+all: reaper
+
+# Pick compiler by preference
+CCPREFS = /usr/bin/musl-gcc /usr/bin/gcc
+CC = $(word 1,$(shell ls $(CCPREFS) 2>/dev/null))
+
+CFLAGS = -Wall -static -O3 -flto
+
+reaper: reaper.c
+ $(CC) $(CFLAGS) -o $@ $^
+
+clean:
+ rm -f reaper
--- /dev/null
+/**
+ * This program waits for child process and "reaps" them, i.e. read
+ * off their status so that they can terminate. The program exits when
+ * it runs out of children.
+ */
+#include <signal.h>
+#include <string.h>
+#include <sys/wait.h>
+
+int main(void) {
+ sigset_t set;
+ siginfo_t status;
+
+ sigfillset(&set);
+ sigprocmask(SIG_BLOCK,&set,NULL);
+
+ do {
+ memset( &status, 0, sizeof( status ) );
+ } while ( waitid( P_ALL, 0, &status, WEXITED ) == 0 );
+ return 0;
+}
--- /dev/null
+//#include <errno.h>
+//#include <signal.h>
+//#include <string.h>
+//#include <unistd.h>
+//#include <sys/wait.h>
+//#include <sys/types.h>
+
+//int main(void) {
+// sigset_t set;
+// siginfo_t status;
+//
+// if (getpid()!=1)
+// return 1;
+// sigfillset(&set);
+// sigprocmask(SIG_BLOCK,&set,NULL);
+// memset(&status,0,sizeof status);
+// while (-ECHILD!=waitid(P_ALL,0,&status,WEXITED));
+// return 1;
+//}
+
+#define _GNU_SOURCE
+
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/syscall.h>
+#include <linux/unistd.h>
+
+static inline void nsl_exit1(void) {
+ asm("mov $60,%eax");
+ asm("mov $1,%rdi");
+ asm("syscall");
+}
+
+__attribute__((naked)) void _start(void) {
+ nsl_exit1();
+}