This commit is contained in:
Robert Morris 2020-08-15 05:46:32 -04:00 committed by Frans Kaashoek
parent f2ec6777bd
commit 95dad4c061
3 changed files with 21 additions and 15 deletions

View file

@ -31,8 +31,20 @@ main(void)
printf("init: exec sh failed\n");
exit(1);
}
while((wpid=wait(0)) >= 0 && wpid != pid){
//printf("zombie!\n");
for(;;){
// this call to wait() returns if the shell exits,
// or if a parentless process exits.
wpid = wait((int *) 0);
if(wpid == pid){
// the shell exited; restart it.
break;
} else if(wpid < 0){
printf("init: wait returned an error\n");
exit(1);
} else {
// it was a parentless process; do nothing.
}
}
}
}

View file

@ -1,4 +1,4 @@
# Initial process execs /init.
# Initial process that execs /init.
# This code runs in user space.
#include "syscall.h"