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

Re: [MiNT] vfork bug, help needed



Hi,

Thomas, I have read your hints but they weren't the reason for the bug.
Actually it had nothing to do with vfork (fork showed the same effect).

Pwaitpid with a WAIT_MYPGRP worked only for the process group leader.
The patch at the end of this mail fixes the bug.  Therefore the waitpid in
the vfork test failed and therefore the status of the child could not be
checked and therefore the test failed.  BTW, in the vfork kit, I forgot to
mention that the bug only appeared if you invoked the test program from
a shell script (because then the parent pid in the test program wasn't
equal to its pid).

I can't think of any work-around in the libc for this.  I think users with
older kernels will have to live with that.

Ciao

Guido

--- dosmem.c.waitpid	Sun Nov 21 16:17:04 1999
+++ dosmem.c	Fri Mar 10 19:15:58 2000
@@ -1428,12 +1428,14 @@
 {
 	long r;
 	PROC *p, *q;
-	int ourpid;
+	int ourpid, ourpgrp;
 	int found;
 
 	TRACE(("Pwaitpid(%d, %d, %lx)", pid, nohang, rusage));
-	ourpid = curproc->pid;
 
+	ourpid = curproc->pid;
+	ourpgrp = curproc->pgrp;
+	
 /* if there are terminated children, clean up and return their info;
  * if there are children, but still running, wait for them;
  * if there are no children, return an error
@@ -1447,7 +1449,7 @@
 			if ((p->ppid == ourpid || p->ptracer == curproc)
 				&& (pid == -1
 					|| (pid > 0 && pid == p->pid)
-					|| (pid == 0 && p->pgrp == ourpid)
+					|| (pid == 0 && p->pgrp == ourpgrp)
 					|| (pid < -1 && p->pgrp == -pid)))
 			{
 				found++;