aboutsummaryrefslogtreecommitdiffstats
path: root/tests/signal-interrupt.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2023-06-25 23:22:40 +0200
committerMattias Andrée <maandree@kth.se>2023-06-25 23:22:40 +0200
commitfd6bd9d9090213d4644fc0a96f06fb34ce5365fc (patch)
treee2d5facad8bb34b84596ee07999fe588dd0c42fc /tests/signal-interrupt.c
parentAdd more test cases (diff)
downloadsctrace-fd6bd9d9090213d4644fc0a96f06fb34ce5365fc.tar.gz
sctrace-fd6bd9d9090213d4644fc0a96f06fb34ce5365fc.tar.bz2
sctrace-fd6bd9d9090213d4644fc0a96f06fb34ce5365fc.tar.xz
Some code improvements
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--tests/signal-interrupt.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/signal-interrupt.c b/tests/signal-interrupt.c
new file mode 100644
index 0000000..7b6988f
--- /dev/null
+++ b/tests/signal-interrupt.c
@@ -0,0 +1,26 @@
+#include <signal.h>
+#include <time.h>
+#include <unistd.h>
+
+static void
+interrupt()
+{
+ write(-2, "xyzzy\n", 6);
+}
+
+int
+main(void)
+{
+ struct timespec ts = {0, 100000000L};
+ pid_t pid = getpid();
+ signal(SIGINT, interrupt);
+ if (fork() == 0) {
+ ts.tv_nsec /= 2;
+ nanosleep(&ts, NULL);
+ kill(pid, SIGINT);
+ } else {
+ nanosleep(&ts, NULL);
+ write(-1, "qwerty\n", 7);
+ }
+ return 0;
+}