diff options
author | attilio <attilio@FreeBSD.org> | 2007-06-09 18:56:11 +0000 |
---|---|---|
committer | attilio <attilio@FreeBSD.org> | 2007-06-09 18:56:11 +0000 |
commit | c105658c88a2c2055d81325040ae51c145564d21 (patch) | |
tree | 5f11084a1ca726fd09afccfce5eb4c0055b06e97 /sys/compat | |
parent | 35719cd36d18abec5f4a2477062825a4a0fe6ead (diff) | |
download | FreeBSD-src-c105658c88a2c2055d81325040ae51c145564d21.zip FreeBSD-src-c105658c88a2c2055d81325040ae51c145564d21.tar.gz |
The current rusage code show peculiar problems:
- Unsafeness on ruadd() in thread_exit()
- Unatomicity of thread_exiit() in the exit1() operations
This patch addresses these problems allocating p_fd as part of the
process and modifying the way it is accessed.
A small chunk of this patch, resolves a race about p_state in kern_wait(),
since we have to be sure about the zombif-ing process.
Submitted by: jeff
Approved by: jeff (mentor)
Diffstat (limited to 'sys/compat')
-rw-r--r-- | sys/compat/svr4/svr4_misc.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/sys/compat/svr4/svr4_misc.c b/sys/compat/svr4/svr4_misc.c index 71d994d..7277622 100644 --- a/sys/compat/svr4/svr4_misc.c +++ b/sys/compat/svr4/svr4_misc.c @@ -1226,19 +1226,21 @@ loop: nfound++; + PROC_SLOCK(p); /* * See if we have a zombie. If so, WNOWAIT should be set, * as otherwise we should have called kern_wait() up above. */ if ((p->p_state == PRS_ZOMBIE) && ((uap->options & (SVR4_WEXITED|SVR4_WTRAPPED)))) { + PROC_SUNLOCK(p); KASSERT(uap->options & SVR4_WNOWAIT, ("WNOWAIT is clear")); /* Found a zombie, so cache info in local variables. */ pid = p->p_pid; status = p->p_xstat; - ru = *p->p_ru; + ru = p->p_ru; calcru(p, &ru.ru_utime, &ru.ru_stime); PROC_UNLOCK(p); sx_sunlock(&proctree_lock); @@ -1253,7 +1255,6 @@ loop: * See if we have a stopped or continued process. * XXX: This duplicates the same code in kern_wait(). */ - PROC_SLOCK(p); if ((p->p_flag & P_STOPPED_SIG) && (p->p_suspcount == p->p_numthreads) && (p->p_flag & P_WAITED) == 0 && @@ -1264,7 +1265,7 @@ loop: sx_sunlock(&proctree_lock); pid = p->p_pid; status = W_STOPCODE(p->p_xstat); - ru = *p->p_ru; + ru = p->p_ru; calcru(p, &ru.ru_utime, &ru.ru_stime); PROC_UNLOCK(p); @@ -1285,7 +1286,7 @@ loop: if (((uap->options & SVR4_WNOWAIT)) == 0) p->p_flag &= ~P_CONTINUED; pid = p->p_pid; - ru = *p->p_ru; + ru = p->p_ru; status = SIGCONT; calcru(p, &ru.ru_utime, &ru.ru_stime); PROC_UNLOCK(p); |