From d54dcb2efc4be344900a7721ac4b65b47840c5d2 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Tue, 26 Jul 2022 22:21:52 +0200 Subject: user/libc: exit() What an interesting commit. --- src/user/lib/esemaphore.c | 4 ++-- src/user/lib/fs/misc.c | 12 ++++++------ src/user/lib/include/unistd.h | 1 + src/user/lib/stdlib.c | 4 ++++ 4 files changed, 13 insertions(+), 8 deletions(-) (limited to 'src/user/lib') diff --git a/src/user/lib/esemaphore.c b/src/user/lib/esemaphore.c index 3a4a836..70cedae 100644 --- a/src/user/lib/esemaphore.c +++ b/src/user/lib/esemaphore.c @@ -26,10 +26,10 @@ struct evil_sem *esem_new(int value) { while (_syscall_read(ends_signal[0], NULL, 0, 0) >= 0) { if (!_syscall_fork(FORK_NOREAP, NULL)) { _syscall_write(ends_wait[1], NULL, 0, 0); - _syscall_exit(0); + exit(0); } } - _syscall_exit(0); + exit(0); } close(ends_signal[0]); close(ends_wait[1]); diff --git a/src/user/lib/fs/misc.c b/src/user/lib/fs/misc.c index 3a248ec..3a732af 100644 --- a/src/user/lib/fs/misc.c +++ b/src/user/lib/fs/misc.c @@ -23,7 +23,7 @@ void fs_passthru(const char *prefix) { const size_t buf_len = 1024; char *buf = malloc(buf_len); int prefix_len = prefix ? strlen(prefix) : 0; - if (!buf) _syscall_exit(1); + if (!buf) exit(1); while (!_syscall_fs_wait(buf, buf_len, &res)) { switch (res.op) { @@ -49,7 +49,7 @@ void fs_passthru(const char *prefix) { break; } } - _syscall_exit(0); + exit(0); } void fs_whitelist(const char **list) { @@ -57,7 +57,7 @@ void fs_whitelist(const char **list) { const size_t buf_len = 1024; char *buf = malloc(buf_len); bool allow; - if (!buf) _syscall_exit(1); + if (!buf) exit(1); while (!_syscall_fs_wait(buf, buf_len, &res)) { switch (res.op) { @@ -79,7 +79,7 @@ void fs_whitelist(const char **list) { break; } } - _syscall_exit(0); + exit(0); } @@ -96,7 +96,7 @@ void fs_dir_inject(const char *path) { char *buf = malloc(buf_len); int ret, inject_len; - if (!buf) _syscall_exit(1); + if (!buf) exit(1); while (!_syscall_fs_wait(buf, buf_len, &res)) { data = res.id; @@ -162,5 +162,5 @@ void fs_dir_inject(const char *path) { break; } } - _syscall_exit(0); + exit(0); } diff --git a/src/user/lib/include/unistd.h b/src/user/lib/include/unistd.h index 4a30298..b825e45 100644 --- a/src/user/lib/include/unistd.h +++ b/src/user/lib/include/unistd.h @@ -3,3 +3,4 @@ int fork(void); int close(handle_t h); +_Noreturn void exit(int); diff --git a/src/user/lib/stdlib.c b/src/user/lib/stdlib.c index 6f276bd..068635b 100644 --- a/src/user/lib/stdlib.c +++ b/src/user/lib/stdlib.c @@ -10,3 +10,7 @@ int fork(void) { int close(handle_t h) { return _syscall_close(h); } + +_Noreturn void exit(int c) { + _syscall_exit(c); +} -- cgit v1.2.3