DragonFly BSD
DragonFly bugs List (threaded) for 2005-12
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: waitpid() with WUNTRACED flag? (was Re: Hang on ctrl+Z after the MPSAFE tsleep/wakeup commit)


From: YONETANI Tomokazu <qhwt+dfly@xxxxxxxxxx>
Date: Tue, 27 Dec 2005 17:21:22 +0900

On Mon, Dec 26, 2005 at 11:27:44PM -0800, Matthew Dillon wrote:
> :Content-Type: text/plain; charset=us-ascii
> :Content-Disposition: attachment; filename="a.c"
> :...
> 
>     I think it's the same issue.  The ^Z effects all processes in
>     the process group.  waitpid in the parent tries to return the
>     stopped state of the child, but the parent itself is stopped
>     and the status is not returned until you 'fg'.  This starts
>     both parent and child, but then the parent processes the
>     return from the waitpid and stops itself again.

Ok, the code doesn't really reflect my question here; on computers here
running other OSes, including DragonFly 1.2.x-RELEASE, waitpid() (or wait4)
doesn't return after ^Z+`fg' even with WUNTRACED (I can confirm this by the
fact that warnx() doesn't print "WSTOPSIG(%d) = %d\n" message), thus no such
problem exists.  I don't know if it's an (POSIX-ly or SUS-ly?) expected
behavior, but are we going to change that?

> :	for (;;) {
> :		caught = waitpid(pid, &st, WUNTRACED);
> :		warnx("waitpid returned %d\n", caught);
> :		errno = WEXITSTATUS(st);
> :		if (caught == -1)
> :			return 1;
> :		else if (WIFSTOPPED(st)) {
> :			sig = WSTOPSIG(st);
> :			warnx("WSTOPSIG(%d) = %d\n", st, sig);
> :			sig = SIGSTOP;
> :			raise(sig);
> :			warnx("after raise(%d)\n", sig);
> :		}



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]