aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--LICENSE2
-rw-r--r--Makefile29
-rw-r--r--test.c9
-rw-r--r--tinysleep.c9
5 files changed, 49 insertions, 3 deletions
diff --git a/.gitignore b/.gitignore
index 5358cd7..6da38a3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,6 @@
*.o
*.su
/pdeath
+/tinysleep
+/test
+/.testdir
diff --git a/LICENSE b/LICENSE
index 028f3a3..383201c 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
ISC License
-© 2016 Mattias Andrée <maandree@kth.se>
+© 2016, 2017 Mattias Andrée <maandree@kth.se>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
diff --git a/Makefile b/Makefile
index 8df5b80..04892ec 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@
CONFIGFILE = config.mk
include $(CONFIGFILE)
-all: pdeath
+all: pdeath tinysleep test
.o:
$(CC) -o $@ $^ $(LDFLAGS)
@@ -11,6 +11,31 @@ all: pdeath
.c.o:
$(CC) -o $@ $< $(CPPFLAGS) $(CFLAGS)
+check: pdeath tinysleep test
+ ./pdeath -L >/dev/null
+ ./pdeath -L | grep ABRT >/dev/null
+ ./pdeath -L | grep FPE >/dev/null
+ ./pdeath -L | grep ILL >/dev/null
+ ./pdeath -L | grep INT >/dev/null
+ ./pdeath -L | grep SEGV >/dev/null
+ ./pdeath -L | grep TERM >/dev/null
+ ! ./pdeath 2>/dev/null
+ ! ./pdeath KILL 2>/dev/null
+ ./pdeath KILL true
+ ! ./pdeath KILL false
+ ./pdeath 1 true
+ ./pdeath 1+1 true
+ ./pdeath 2-1 true
+ ! ./pdeath - true 2>/dev/null
+ ! ./test
+ ./pdeath KILL ./test
+ mkdir -p .testdir
+ sleep 1 & printf '%i\n' $$! > .testdir/pid; ./tinysleep
+ kill -0 $$(cat .testdir/pid)
+ ./pdeath KILL sleep 1 & printf '%i\n' $$! > .testdir/pid; ./tinysleep
+ ! kill -0 $$(cat .testdir/pid) 2>/dev/null
+ rm -r .testdir
+
install: pdeath
mkdir -p -- "$(DESTDIR)$(PREFIX)/bin"
mkdir -p -- "$(DESTDIR)$(PREFIX)/share/licenses/pdeath"
@@ -25,7 +50,7 @@ uninstall:
-rm -rf -- "$(DESTDIR)$(PREFIX)/share/licenses/pdeath"
clean:
- -rm -f -- *.o pdeath
+ -rm -rf -- *.o pdeath .testdir
SUFFIXES: .o .c.o
diff --git a/test.c b/test.c
new file mode 100644
index 0000000..082a952
--- /dev/null
+++ b/test.c
@@ -0,0 +1,9 @@
+/* See LICENSE file for copyright and license details. */
+#include <sys/prctl.h>
+
+int
+main(void)
+{
+ int val = 0;
+ return prctl(PR_GET_PDEATHSIG, &val) || !val;
+}
diff --git a/tinysleep.c b/tinysleep.c
new file mode 100644
index 0000000..5c00a59
--- /dev/null
+++ b/tinysleep.c
@@ -0,0 +1,9 @@
+/* See LICENSE file for copyright and license details. */
+#include <unistd.h>
+
+int
+main(void)
+{
+ usleep(50000L);
+ return 0;
+}