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