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