xref: /xv6-public/init.c (revision e958c538)
1 #include "types.h"
2 #include "stat.h"
3 #include "user.h"
4 #include "fs.h"
5 #include "fcntl.h"
6 
7 char *sh_args[] = { "sh", 0 };
8 
9 int
10 main(void)
11 {
12   int pid;
13 
14   if(open("console", 0) < 0){
15     mknod("console", T_DEV, 1, 1);
16     open("console", 0);
17   }
18   open("console", 1);
19   open("console", 1);
20 
21   while(1){
22     pid = fork();
23     if(pid == 0){
24       exec("sh", sh_args);
25       exit();
26     }
27     if(pid > 0)
28       wait();
29   }
30 }
31