"ps -e" without procfs(5)
Mikolaj Golub
trociny at freebsd.org
Thu Nov 10 21:15:17 UTC 2011
On Wed, 09 Nov 2011 15:31:26 +0200 Mikolaj Golub wrote:
MG> On Wed, 9 Nov 2011 14:53:29 +0200 Kostik Belousov wrote:
>>> And now you return success and nothing gets copied out for the process
>>> in P_INEXEC state. Either you should return an error like EAGAIN, or
>>> consider the P_INEXEC state as transitional and wait till process
>>> leaves it. Or, ignore the state as it was before, and return whatever
>>> error proc_rwmem generated (my preference).
KB>> Forgot to say that the check does not change much because you drop
KB>> process lock immediately after the check, so the process may enter
KB>> the INEXEC state right after the check. I believe you already tried
KB>> to do this with P_WEXIT.
MG> Good point :-). Although after adding the P_INEXEC I have not seen errors any
MG> more, while before they were often (when running 'procstat -ca' in loop and
MG> building world simultaneously). Thus it looks like the probability is much
MG> smaller.
MG> So, it still looks good for me to check for P_INEXEC and return EAGAIN, and
MG> add the comment why we do this and that it still racy. But if you still think
MG> that ignoring the state is the best option no problems for me to return it
MG> back.
Realted to this, sysctl_kern_proc_kstack() looks like has the similar issue.
But it returns ESRCH instead.
/* XXXRW: Not clear ESRCH is the right error during proc execve(). */
if (p->p_flag & P_WEXIT || p->p_flag & P_INEXEC) {
PROC_UNLOCK(p);
return (ESRCH);
}
...
_PHOLD(p);
PROC_UNLOCK(p);
--
Mikolaj Golub
More information about the freebsd-hackers
mailing list