diff options
Diffstat (limited to 'src/init')
-rw-r--r-- | src/init/fs/misc.c | 4 | ||||
-rw-r--r-- | src/init/main.c | 6 | ||||
-rw-r--r-- | src/init/shell.c | 2 | ||||
-rw-r--r-- | src/init/syscalls.c | 4 | ||||
-rw-r--r-- | src/init/tests/main.c | 10 |
5 files changed, 13 insertions, 13 deletions
diff --git a/src/init/fs/misc.c b/src/init/fs/misc.c index b962b64..ca3128d 100644 --- a/src/init/fs/misc.c +++ b/src/init/fs/misc.c @@ -53,7 +53,7 @@ static void fs_respond_delegate(struct fs_wait_response *res, handle_t delegate, switch (res->op) { case VFSOP_READ: - if (_syscall_fork()) { + if (_syscall_fork(FORK_NOREAP)) { // handle reads in a child // this is a HORRIBLE workaround for making concurrent IO work without proper delegates break; @@ -62,7 +62,7 @@ static void fs_respond_delegate(struct fs_wait_response *res, handle_t delegate, size = res->capacity < sizeof(buf) ? res->capacity : sizeof(buf); ret = _syscall_read(delegate, buf, size, res->offset); _syscall_fs_respond(buf, ret); - _syscall_exit(0); // TODO unreapable - add a nonblocking reap syscall + _syscall_exit(0); break; // TODO proper writing (see above) diff --git a/src/init/main.c b/src/init/main.c index 5601526..5db1333 100644 --- a/src/init/main.c +++ b/src/init/main.c @@ -28,7 +28,7 @@ int main(void) { MOUNT("/bind/", fs_passthru(NULL)); - if (_syscall_fork()) { + if (_syscall_fork(0)) { /* (used to) expose a bug in the kernel * the program will flow like this: * 1. we launch the forked init @@ -45,7 +45,7 @@ int main(void) { _syscall_exit(1); } - if (!_syscall_fork()) { + if (!_syscall_fork(0)) { if (file_open(&__stdout, "/com1") < 0 || file_open(&__stdin, "/com1") < 0) _syscall_exit(1); @@ -54,7 +54,7 @@ int main(void) { } - if (!_syscall_fork()) { + if (!_syscall_fork(0)) { if (file_open(&__stdout, "/vga_tty") < 0) _syscall_exit(1); diff --git a/src/init/shell.c b/src/init/shell.c index d723731..e7c836f 100644 --- a/src/init/shell.c +++ b/src/init/shell.c @@ -145,7 +145,7 @@ void shell_loop(void) { } else if (!strcmp(cmd, "exit")) { _syscall_exit(0); } else if (!strcmp(cmd, "fork")) { - if (_syscall_fork()) + if (_syscall_fork(0)) _syscall_await(); else level++; } else if (!strcmp(cmd, "run_tests")) { diff --git a/src/init/syscalls.c b/src/init/syscalls.c index 15acd1c..a374976 100644 --- a/src/init/syscalls.c +++ b/src/init/syscalls.c @@ -6,8 +6,8 @@ _Noreturn void _syscall_exit(int ret) { __builtin_unreachable(); } -int _syscall_fork(void) { - return _syscall(_SYSCALL_FORK, 0, 0, 0, 0); +int _syscall_fork(int flags) { + return _syscall(_SYSCALL_FORK, flags, 0, 0, 0); } int _syscall_await(void) { diff --git a/src/init/tests/main.c b/src/init/tests/main.c index ed50229..ac8874f 100644 --- a/src/init/tests/main.c +++ b/src/init/tests/main.c @@ -12,7 +12,7 @@ #define assert(cond) if (!(cond)) test_fail(); static void run_forked(void (*fn)()) { - if (!_syscall_fork()) { + if (!_syscall_fork(0)) { fn(); _syscall_exit(0); } else { @@ -31,7 +31,7 @@ static void test_await(void) { int counts[16] = {0}; for (int i = 0; i < 16; i++) - if (!_syscall_fork()) + if (!_syscall_fork(0)) _syscall_exit(i); while ((ret = _syscall_await()) != ~0) { @@ -49,12 +49,12 @@ static void test_faults(void) { * reap all its children */ int await_cnt = 0; - if (!_syscall_fork()) { // invalid memory access + if (!_syscall_fork(0)) { // invalid memory access asm volatile("movb $69, 0" ::: "memory"); printf("this shouldn't happen"); _syscall_exit(-1); } - if (!_syscall_fork()) { // #GP + if (!_syscall_fork(0)) { // #GP asm volatile("hlt" ::: "memory"); printf("this shouldn't happen"); _syscall_exit(-1); @@ -94,7 +94,7 @@ static void test_orphaned_fs(void) { static void stress_fork(void) { /* run a lot of processes */ for (size_t i = 0; i < 2048; i++) { - if (!_syscall_fork()) _syscall_exit(0); + if (!_syscall_fork(0)) _syscall_exit(0); _syscall_await(); } } |