wait3() does not always return in 4.2

rws%mit-bold at sri-unix.UUCP rws%mit-bold at sri-unix.UUCP
Wed Nov 16 05:56:35 AEST 1983


From:  Robert W. Scheifler <rws at mit-bold>

When doing a wait3() with WUNTRACED with a SIGCHLD handler, if the inferior
stops due to a SIGTTIN, SIGTTOU, SIGTSTP, or SIGSTOP after the parent is
already sleeping at PWAIT, the wait3() never returns.  This is a result
of the crufty old wait3(). What SHOULD have been done, since a new wait
system call was added for 4.2, is that wait3() should have been the standard
system call, and wait() should have been made a library routine that did
wait3(status, 0, 0).  However, the disgusting old 4.1 code that has wait3()
setting magic condition codes and placing the extra arguments in registers
still persists.  The magic condition codes get clobbered when the wait3()
system call gets restarted, which happens when the SIGCHLD occurs.  In
/sys/vax/trap.c, in syscall(), the following is done even for RESTARTSYS:
	locr0[PS] &= ~PSL_C;
Since wait3() is indicated by all the bits being set, the restarted wait3()
turns into a wait(), and you never terminate.  The fix is to move the
offending statement down inside the final else of the following if statement:
	if (u.u_eosys == RESTARTSYS)
		pc = opc;
#ifdef notdef
	else if (u.u_eosys == SIMULATERTI)
		dorti();
#endif
	else if (u.u_error) {
#ifndef lint
bad:
#endif
		locr0[R0] = u.u_error;
		locr0[PS] |= PSL_C;	/* carry bit */
	} else {
		locr0[PS] &= ~PSL_C;	/* clear carry bit */
		locr0[R0] = u.u_r.r_val1;
		locr0[R1] = u.u_r.r_val2;
	}



More information about the Comp.unix.wizards mailing list