From fd6bd9d9090213d4644fc0a96f06fb34ce5365fc Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 25 Jun 2023 23:22:40 +0200 Subject: Some code improvements MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- tests/Makefile | 2 ++ tests/abort-nodump.c | 9 +++++++++ tests/abort.c | 2 ++ tests/signal-interrupt.c | 26 ++++++++++++++++++++++++++ 4 files changed, 39 insertions(+) create mode 100644 tests/abort-nodump.c create mode 100644 tests/signal-interrupt.c (limited to 'tests') diff --git a/tests/Makefile b/tests/Makefile index 7468bfa..527c690 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -2,6 +2,7 @@ BIN_64 =\ abort.64\ + abort-nodump.64\ cont.64\ exec.64\ exit.64\ @@ -13,6 +14,7 @@ BIN_64 =\ raise.64\ siginfo.64\ signal.64\ + signal-interrupt.64\ stop.64\ threads.64\ tstp.64\ diff --git a/tests/abort-nodump.c b/tests/abort-nodump.c new file mode 100644 index 0000000..9e13595 --- /dev/null +++ b/tests/abort-nodump.c @@ -0,0 +1,9 @@ +#include +#include + +int +main(void) +{ + prctl(PR_SET_DUMPABLE, 0); + abort(); +} diff --git a/tests/abort.c b/tests/abort.c index 3afda7b..aa9dac9 100644 --- a/tests/abort.c +++ b/tests/abort.c @@ -1,7 +1,9 @@ +#include #include int main(void) { + prctl(PR_SET_DUMPABLE, 1); abort(); } 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 +#include +#include + +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; +} -- cgit v1.2.3-70-g09d2