This commit is contained in:
Robert Morris 2019-07-20 18:51:31 -04:00
parent 06e49a58dc
commit 328204d9cc

View file

@ -319,13 +319,12 @@ void
exit(void) exit(void)
{ {
struct proc *p = myproc(); struct proc *p = myproc();
int fd;
if(p == initproc) if(p == initproc)
panic("init exiting"); panic("init exiting");
// Close all open files. // Close all open files.
for(fd = 0; fd < NOFILE; fd++){ for(int fd = 0; fd < NOFILE; fd++){
if(p->ofile[fd]){ if(p->ofile[fd]){
struct file *f = p->ofile[fd]; struct file *f = p->ofile[fd];
fileclose(f); fileclose(f);
@ -342,14 +341,14 @@ exit(void)
acquire(&p->lock); acquire(&p->lock);
// Give our children to init. // Give any children to init.
reparent(p, p->parent); reparent(p, p->parent);
p->state = ZOMBIE;
// Parent might be sleeping in wait(). // Parent might be sleeping in wait().
wakeup1(p->parent); wakeup1(p->parent);
p->state = ZOMBIE;
release(&p->parent->lock); release(&p->parent->lock);
// Jump into the scheduler, never to return. // Jump into the scheduler, never to return.