diff options
Diffstat (limited to 'src/user')
-rw-r--r-- | src/user/app/init/init.c | 1 | ||||
-rw-r--r-- | src/user/app/tests/kernel/miscsyscall.c | 16 | ||||
-rw-r--r-- | src/user/app/tests/libc/esemaphore.c | 1 | ||||
-rw-r--r-- | src/user/app/tests/tests.c | 5 | ||||
-rw-r--r-- | src/user/lib/syscall.c | 4 |
5 files changed, 25 insertions, 2 deletions
diff --git a/src/user/app/init/init.c b/src/user/app/init/init.c index 96b2eb7..0af0150 100644 --- a/src/user/app/init/init.c +++ b/src/user/app/init/init.c @@ -104,5 +104,6 @@ int main(void) { } _syscall_read(killswitch_pipe[0], NULL, 0, 0); + _syscall_filicide(); return 0; } diff --git a/src/user/app/tests/kernel/miscsyscall.c b/src/user/app/tests/kernel/miscsyscall.c index 66899b1..58a9afb 100644 --- a/src/user/app/tests/kernel/miscsyscall.c +++ b/src/user/app/tests/kernel/miscsyscall.c @@ -26,6 +26,20 @@ static void test_await(void) { test(counts[i] == 1); } +static void test_await2(void) { + /* hangs on failure */ + if (!fork()) { + if (!fork()) { + for (;;) _syscall_sleep(1000000000); + } else { + exit(123); + } + } + test(_syscall_await() == 123); + test(_syscall_await() == ~0); /* don't wait for tombstone */ + _syscall_filicide(); +} + static void test_pipe(void) { const char *pipe_msgs[2] = {"hello", "world"}; handle_t ends[2]; @@ -246,6 +260,7 @@ static void test_sleep(void) { for (;;) _syscall_sleep(1000000000); } _syscall_await(); + _syscall_filicide(); _syscall_exit(0); } @@ -277,6 +292,7 @@ static void test_badopen(void) { void r_k_miscsyscall(void) { run_test(test_await); + run_test(test_await2); run_test(test_pipe); run_test(test_memflag); run_test(test_dup); diff --git a/src/user/app/tests/libc/esemaphore.c b/src/user/app/tests/libc/esemaphore.c index c78dd56..f1856ff 100644 --- a/src/user/app/tests/libc/esemaphore.c +++ b/src/user/app/tests/libc/esemaphore.c @@ -68,6 +68,7 @@ static void test_semaphore(void) { esem_free(sem1); esem_free(sem2); + _syscall_filicide(); exit(0); } else { close(pipe[1]); diff --git a/src/user/app/tests/tests.c b/src/user/app/tests/tests.c index 90a4978..f2f9aa5 100644 --- a/src/user/app/tests/tests.c +++ b/src/user/app/tests/tests.c @@ -10,6 +10,7 @@ FILE *fail_trig; void run_test(void (*fn)()) { if (!fork()) { fn(); + _syscall_filicide(); exit(0); } else { /* successful tests must return 0 */ @@ -41,10 +42,10 @@ int forkpipe(FILE **f, handle_t *h) { int main(void) { handle_t reader; if (!forkpipe(&fail_trig, &reader)) { - r_k_fdlimit(); + r_k_miscsyscall(); r_k_fs(); + r_k_fdlimit(); r_k_misc(); - r_k_miscsyscall(); r_k_path(); r_k_threads(); r_libc_esemaphore(); diff --git a/src/user/lib/syscall.c b/src/user/lib/syscall.c index 50c71a8..d6ed0af 100644 --- a/src/user/lib/syscall.c +++ b/src/user/lib/syscall.c @@ -70,6 +70,10 @@ void _syscall_sleep(long ms) { return (void)_syscall(_SYSCALL_SLEEP, ms, 0, 0, 0, 0); } +void _syscall_filicide(void) { + return (void)_syscall(_SYSCALL_FILICIDE, 0, 0, 0, 0, 0); +} + long _syscall_execbuf(void __user *buf, size_t len) { return _syscall(_SYSCALL_EXECBUF, (long)buf, (long)len, 0, 0, 0); } |