diff options
author | Andreas Kling <awesomekling@gmail.com> | 2018-11-02 20:41:58 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2018-11-02 20:41:58 +0100 |
commit | 8accc92c3c060e5f3d236bc6ee7de90e64900ace (patch) | |
tree | ea21dadcddee2d8cf0bcb3d8259ef1684a7e5ce0 /LibC | |
parent | 10b666f69a610c0bdc5bd60efd1d7d2bf499707d (diff) | |
download | serenity-8accc92c3c060e5f3d236bc6ee7de90e64900ace.zip |
Implement fork()!
This is quite cool! The syscall entry point plumbs the register dump
down to sys$fork(), which uses it to set up the child process's TSS
in order to resume execution right after the int 0x80 fork() call. :^)
This works pretty well, although there is some problem with the kernel
alias mappings used to clone the parent process's regions. If I disable
the MM::release_page_directory() code, there's no problem. Probably there's
a premature freeing of a physical page somehow.
Diffstat (limited to 'LibC')
-rw-r--r-- | LibC/unistd.cpp | 5 | ||||
-rw-r--r-- | LibC/unistd.h | 1 |
2 files changed, 6 insertions, 0 deletions
diff --git a/LibC/unistd.cpp b/LibC/unistd.cpp index 3492430198..9a3b2459b8 100644 --- a/LibC/unistd.cpp +++ b/LibC/unistd.cpp @@ -5,6 +5,11 @@ extern "C" { +pid_t fork() +{ + return Syscall::invoke(Syscall::PosixFork); +} + uid_t getuid() { return Syscall::invoke(Syscall::PosixGetuid); diff --git a/LibC/unistd.h b/LibC/unistd.h index cf2df7e97d..205002dff8 100644 --- a/LibC/unistd.h +++ b/LibC/unistd.h @@ -8,6 +8,7 @@ __BEGIN_DECLS extern char** environ; inline int getpagesize() { return 4096; } +pid_t fork(); pid_t getsid(pid_t); pid_t setsid(); int setpgid(pid_t pid, pid_t pgid); |