clear killed flag in exit
idecref cwd in exit
This commit is contained in:
parent
dfcc5b997c
commit
7a37578e9e
6 changed files with 12 additions and 12 deletions
2
fs.c
2
fs.c
|
@ -632,7 +632,7 @@ unlink(char *cp)
|
||||||
memset(&de, 0, sizeof(de));
|
memset(&de, 0, sizeof(de));
|
||||||
if(writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de))
|
if(writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de))
|
||||||
panic("unlink dir write");
|
panic("unlink dir write");
|
||||||
|
|
||||||
iupdate(dp);
|
iupdate(dp);
|
||||||
iput(dp);
|
iput(dp);
|
||||||
|
|
||||||
|
|
|
@ -150,8 +150,8 @@ createdelete()
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pid)
|
if(pid)
|
||||||
wait();
|
exit();
|
||||||
else
|
else
|
||||||
exit();
|
exit();
|
||||||
|
|
||||||
for(i = 0; i < n; i++){
|
for(i = 0; i < n; i++){
|
||||||
|
@ -160,8 +160,10 @@ createdelete()
|
||||||
fd = open(name, 0);
|
fd = open(name, 0);
|
||||||
if((i == 0 || i >= n/2) && fd < 0){
|
if((i == 0 || i >= n/2) && fd < 0){
|
||||||
printf(1, "oops createdelete %s didn't exist\n", name);
|
printf(1, "oops createdelete %s didn't exist\n", name);
|
||||||
|
exit();
|
||||||
} else if((i >= 1 && i < n/2) && fd >= 0){
|
} else if((i >= 1 && i < n/2) && fd >= 0){
|
||||||
printf(1, "oops createdelete %s did exist\n", name);
|
printf(1, "oops createdelete %s did exist\n", name);
|
||||||
|
exit();
|
||||||
}
|
}
|
||||||
if(fd >= 0)
|
if(fd >= 0)
|
||||||
close(fd);
|
close(fd);
|
||||||
|
@ -171,8 +173,10 @@ createdelete()
|
||||||
fd = open(name, 0);
|
fd = open(name, 0);
|
||||||
if((i == 0 || i >= n/2) && fd < 0){
|
if((i == 0 || i >= n/2) && fd < 0){
|
||||||
printf(1, "oops createdelete %s didn't exist\n", name);
|
printf(1, "oops createdelete %s didn't exist\n", name);
|
||||||
|
exit();
|
||||||
} else if((i >= 1 && i < n/2) && fd >= 0){
|
} else if((i >= 1 && i < n/2) && fd >= 0){
|
||||||
printf(1, "oops createdelete %s did exist\n", name);
|
printf(1, "oops createdelete %s did exist\n", name);
|
||||||
|
exit();
|
||||||
}
|
}
|
||||||
if(fd >= 0)
|
if(fd >= 0)
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
4
proc.c
4
proc.c
|
@ -337,6 +337,9 @@ proc_exit(void)
|
||||||
cp->fds[fd] = 0;
|
cp->fds[fd] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
idecref(cp->cwd);
|
||||||
|
cp->cwd = 0;
|
||||||
|
|
||||||
acquire(&proc_table_lock);
|
acquire(&proc_table_lock);
|
||||||
|
|
||||||
|
@ -351,6 +354,7 @@ proc_exit(void)
|
||||||
p->ppid = 1;
|
p->ppid = 1;
|
||||||
|
|
||||||
// Jump into the scheduler, never to return.
|
// Jump into the scheduler, never to return.
|
||||||
|
cp->killed = 0;
|
||||||
cp->state = ZOMBIE;
|
cp->state = ZOMBIE;
|
||||||
sched();
|
sched();
|
||||||
panic("zombie exit");
|
panic("zombie exit");
|
||||||
|
|
5
proc.h
5
proc.h
|
@ -46,12 +46,7 @@ struct proc{
|
||||||
int killed;
|
int killed;
|
||||||
struct fd *fds[NOFILE];
|
struct fd *fds[NOFILE];
|
||||||
struct inode *cwd;
|
struct inode *cwd;
|
||||||
|
|
||||||
uint esp; // kernel stack pointer
|
|
||||||
uint ebp; // kernel frame pointer
|
|
||||||
|
|
||||||
struct jmpbuf jmpbuf;
|
struct jmpbuf jmpbuf;
|
||||||
|
|
||||||
struct trapframe *tf; // points into kstack, used to find user regs
|
struct trapframe *tf; // points into kstack, used to find user regs
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
2
sh.c
2
sh.c
|
@ -22,7 +22,7 @@ char *argv[MAXARGS];
|
||||||
char argv0buf[BUFSIZ];
|
char argv0buf[BUFSIZ];
|
||||||
int argc;
|
int argc;
|
||||||
|
|
||||||
int debug = 1;
|
int debug = 0;
|
||||||
|
|
||||||
int parse(char *s);
|
int parse(char *s);
|
||||||
void runcmd(void);
|
void runcmd(void);
|
||||||
|
|
|
@ -113,7 +113,6 @@ sys_pipe(void)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
oops:
|
oops:
|
||||||
cprintf("sys_pipe failed\n");
|
|
||||||
if(rfd)
|
if(rfd)
|
||||||
fd_close(rfd);
|
fd_close(rfd);
|
||||||
if(wfd)
|
if(wfd)
|
||||||
|
@ -602,14 +601,12 @@ sys_exec(void)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
bad:
|
bad:
|
||||||
cprintf("exec failed early\n");
|
|
||||||
if(mem)
|
if(mem)
|
||||||
kfree(mem, sz);
|
kfree(mem, sz);
|
||||||
iput(ip);
|
iput(ip);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
bad2:
|
bad2:
|
||||||
cprintf("exec failed late\n");
|
|
||||||
iput(ip);
|
iput(ip);
|
||||||
proc_exit();
|
proc_exit();
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue