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 write(1, "init...\n", 8); 21 22 while(1){ 23 write(1, "running sh...\n", 14); 24 pid = fork(); 25 if(pid == 0){ 26 exec("sh", sh_args); 27 exit(); 28 } 29 if(pid > 0) 30 wait(); 31 } 32 } 33