Initial Upload

This commit is contained in:
iDunnoDev
2022-12-06 11:49:47 +00:00
committed by iDunnoDev
commit 0ee33aaa97
274 changed files with 60109 additions and 0 deletions

35
init.c Normal file
View File

@ -0,0 +1,35 @@
// init: The initial user-level program
#include "types.h"
#include "stat.h"
#include "user.h"
#include "fcntl.h"
char *argv[] = { "sh", 0 };
int main(void) {
int pid, wpid;
if (open("console", O_RDWR) < 0) {
mknod("console", 1, 1);
open("console", O_RDWR);
}
dup(0); // stdout
dup(0); // stderr
for (;;) {
printf(1, "init: starting sh\n");
pid = fork();
if (pid < 0) {
printf(1, "init: fork failed\n");
exit();
}
if (pid == 0) {
exec("sh", argv);
printf(1, "init: exec sh failed\n");
exit();
}
while ((wpid = wait()) >= 0 && wpid != pid) {
}
}
}