proc: add proc_fork and accompanying syscall
Signed-off-by: Michael Shaw <spencershawiscool@gmail.com>
This commit is contained in:
parent
f575a056bf
commit
e7133a473f
8 changed files with 115 additions and 0 deletions
|
|
@ -3,11 +3,13 @@
|
|||
#include <stdint.h>
|
||||
|
||||
typedef int64_t ssize_t;
|
||||
typedef int64_t pid_t;
|
||||
|
||||
int open(const char *pathname, int flags);
|
||||
ssize_t read(int fd, void *buf, int count);
|
||||
ssize_t write(int fd, void *buf, int count);
|
||||
int close(int fd);
|
||||
pid_t fork();
|
||||
int exit(int status);
|
||||
|
||||
void promptfd(int fd)
|
||||
|
|
@ -27,7 +29,18 @@ void _start()
|
|||
|
||||
ssize_t ret;
|
||||
while ((ret = read(fd, c, 1)) > 0) {
|
||||
if (c[0] == '\r')
|
||||
c[0] = '\n';
|
||||
|
||||
write(fd, c, 1);
|
||||
|
||||
if (c[0] == '\n') {
|
||||
write(fd, "attempting to fork\n", 19);
|
||||
if (fork() == 0) {
|
||||
write(fd, "child\n", 6);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exit(0x1234);
|
||||
|
|
|
|||
|
|
@ -16,4 +16,5 @@ _sc_define read, 0
|
|||
_sc_define write, 1
|
||||
_sc_define open, 2
|
||||
_sc_define close, 3
|
||||
_sc_define fork, 57
|
||||
_sc_define exit, 60
|
||||
|
|
|
|||
Loading…
Reference in a new issue