Waitpid seems to be working

This commit is contained in:
2024-04-14 13:08:08 +02:00
parent 4e7989e2a9
commit 180cdd7993
7 changed files with 206 additions and 28 deletions

View File

@@ -30,9 +30,9 @@ extern "C" {
#define SYSCALL_EXECVE_ID 50
#define SYSCALL_FORK_ID 51
#define SYSCALL_WAITPID_ID 52
#define SYSCALL_SBRK_ID 100
#define SYSCALL_PRINT_MEM 1000
#define SYSCALL_PRINT_TASKS 1001

View File

@@ -8,6 +8,7 @@
#include <sys/time.h>
#include <sys/times.h>
#include <sys/types.h>
#include <sys/wait.h>
uint64_t _do_syscall(uint64_t id_rdi, uint64_t a1_rsi, uint64_t a2_rdx, uint64_t a3_rcx) {
register uint64_t res asm("rax");
@@ -92,6 +93,11 @@ int _unlink(char *name) {
}
int _wait(int *status) {
return waitpid(-1, &status, 0);
}
pid_t waitpid(pid_t pid, int *status, int options) {
return _do_syscall(SYSCALL_WAITPID_ID, (uint64_t) pid, (uint64_t) status, (uint64_t) options);
}
int _write(int file, char *ptr, int len) {