summaryrefslogtreecommitdiff
path: root/src/init
diff options
context:
space:
mode:
authordzwdz2021-10-04 21:01:31 +0200
committerdzwdz2021-10-04 21:01:31 +0200
commit1d5e56659af7945daac0f79a06b839bfd59c8f1f (patch)
tree70e9c94177f5877ca9b850294c1aa43fece9cba1 /src/init
parent16a5b4c9ed410daba848a781f8b8978846c6b836 (diff)
remove support for processes returning strings on exit
This isn't really all that useful, it doesn't enable anything that wasn't possible before. With it removed I'll be able to implement process_exit() in a much simpler way.
Diffstat (limited to 'src/init')
-rw-r--r--src/init/main.c20
-rw-r--r--src/init/syscalls.c8
2 files changed, 12 insertions, 16 deletions
diff --git a/src/init/main.c b/src/init/main.c
index 5c798d2..71a2d4e 100644
--- a/src/init/main.c
+++ b/src/init/main.c
@@ -23,7 +23,7 @@ int main(void) {
tty_fd = _syscall_open("/tty", sizeof("/tty") - 1);
if (tty_fd < 0)
- _syscall_exit(argify("couldn't open tty"));
+ _syscall_exit(1);
fs_test();
test_await();
@@ -32,7 +32,7 @@ int main(void) {
while (_syscall_read(tty_fd, &c, 1, 0))
_syscall_write(tty_fd, &c, 1, 0);
- _syscall_exit(argify("my job here is done."));
+ _syscall_exit(0);
}
void read_file(const char *path, size_t len) {
@@ -83,19 +83,15 @@ void fs_test(void) {
}
void test_await(void) {
- char buf[16];
- int len;
+ int ret;
- // the child immediately dies
- if (!_syscall_fork())
- _syscall_exit(argify("i'm dead"));
- if (!_syscall_fork())
- _syscall_exit(argify("i'm also dead"));
+ if (!_syscall_fork()) _syscall_exit(69);
+ if (!_syscall_fork()) _syscall_exit(420);
- while ((len = _syscall_await(buf, 16)) >= 0) {
+ while ((ret = _syscall_await()) != ~0) {
log("await returned: ");
- _syscall_write(tty_fd, buf, len, 0);
+ //_syscall_write(tty_fd, buf, len, 0); TODO printf
log("\n");
}
- log("await: negative len\n");
+ log("await: no more children\n");
}
diff --git a/src/init/syscalls.c b/src/init/syscalls.c
index f32594e..57a7344 100644
--- a/src/init/syscalls.c
+++ b/src/init/syscalls.c
@@ -1,8 +1,8 @@
// this file could probably just get generated by a script
#include <shared/syscalls.h>
-_Noreturn void _syscall_exit(const char __user *msg, size_t len) {
- _syscall(_SYSCALL_EXIT, (int)msg, len, 0, 0);
+_Noreturn void _syscall_exit(int ret) {
+ _syscall(_SYSCALL_EXIT, ret, 0, 0, 0);
__builtin_unreachable();
}
@@ -10,8 +10,8 @@ int _syscall_fork(void) {
return _syscall(_SYSCALL_FORK, 0, 0, 0, 0);
}
-int _syscall_await(char __user *buf, int len) {
- return _syscall(_SYSCALL_AWAIT, (int)buf, (int)len, 0, 0);
+int _syscall_await(void) {
+ return _syscall(_SYSCALL_AWAIT, 0, 0, 0, 0);
}
handle_t _syscall_open(const char __user *path, int len) {