kernel+libc+init: Add getppid() and wait()
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
7efcc06090
commit
e76ccd6c4c
@ -47,5 +47,5 @@ int main()
|
||||
return 1;
|
||||
}
|
||||
|
||||
while (1) { waitpid(-1, NULL, 0); }
|
||||
while (1) wait(NULL);
|
||||
}
|
||||
|
@ -5,3 +5,8 @@ Result<u64> sys_getpid(Registers*, SyscallArgs)
|
||||
{
|
||||
return Scheduler::current()->id;
|
||||
}
|
||||
|
||||
Result<u64> sys_getppid(Registers*, SyscallArgs)
|
||||
{
|
||||
return Scheduler::current()->parent_id;
|
||||
}
|
||||
|
@ -14,6 +14,9 @@ extern "C"
|
||||
/* Wait for a child process to exit. */
|
||||
pid_t waitpid(pid_t pid, int* status, int options);
|
||||
|
||||
/* Wait for any child process to exit. */
|
||||
pid_t wait(int* status);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -25,6 +25,9 @@ extern "C"
|
||||
/* Return the current process' process ID. */
|
||||
pid_t getpid(void);
|
||||
|
||||
/* Return the current process' parent process ID. */
|
||||
pid_t getppid(void);
|
||||
|
||||
/* Replace the current process with another one. On success, does not return. */
|
||||
int execv(const char* path, char* const* argv);
|
||||
|
||||
|
@ -10,4 +10,9 @@ extern "C"
|
||||
long rc = syscall(SYS_waitpid, pid, status, options);
|
||||
__errno_return(rc, pid_t);
|
||||
}
|
||||
|
||||
pid_t wait(int* status)
|
||||
{
|
||||
return waitpid(-1, status, 0);
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,11 @@ extern "C"
|
||||
return (pid_t)syscall(SYS_getpid);
|
||||
}
|
||||
|
||||
pid_t getppid(void)
|
||||
{
|
||||
return (pid_t)syscall(SYS_getppid);
|
||||
}
|
||||
|
||||
int execv(const char* path, char* const* argv)
|
||||
{
|
||||
long rc = syscall(SYS_exec, path, argv);
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#define enumerate_syscalls(_e) \
|
||||
_e(exit) _e(clock_gettime) _e(mmap) _e(munmap) _e(usleep) _e(open) _e(close) _e(read) _e(getpid) _e(write) \
|
||||
_e(lseek) _e(mkdir) _e(exec) _e(mknod) _e(fork) _e(waitpid)
|
||||
_e(lseek) _e(mkdir) _e(exec) _e(mknod) _e(fork) _e(waitpid) _e(getppid)
|
||||
|
||||
enum Syscalls
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user