Subject: Re: Truncated output from ptys at slave exit
To: Michael Eriksson <Michael.Eriksson@era-t.ericsson.se>
From: enami tsugutomo <enami@sm.sony.co.jp>
List: tech-kern
Date: 09/06/2003 09:20:37
I wrote:
> 
> It looks like SA bug.  ltsleep(PCATCH) called inside exit1() returns
> EINTR.  So, ttywait() fails to drain output.

Here is possible change.  As the lwp first entered exit1() waits other
lwps to exit, I guess this fixes it (at least it did for the supplied
test case).  There is pool_get() before the wait but since it doesn't
set PCATCH, it is safe (anyway, we can defer it).

# or revisit as commented before we have tons of hack.
enami.

I've manually edited this to remove local mods, so sorry if it didn't
applied cleanly.

Index: kern_synch.c
===================================================================
RCS file: /cvsroot/src/sys/kern/kern_synch.c,v
retrieving revision 1.136
diff -c -r1.136 kern_synch.c
*** kern_synch.c	2003/08/07 16:31:50	1.136
--- kern_synch.c	2003/09/05 23:57:30
***************
*** 467,473 ****
  	 */
  	if (catch) {
  		l->l_flag |= L_SINTR;
! 		if (((sig = CURSIG(l)) != 0) || (p->p_flag & P_WEXIT)) {
  			if (l->l_wchan != NULL)
  				unsleep(l);
  			l->l_stat = LSONPROC;
--- 471,478 ----
  	 */
  	if (catch) {
  		l->l_flag |= L_SINTR;
! 		if (((sig = CURSIG(l)) != 0) ||
! 		    (p->p_flag & P_WEXIT && p->p_nlwps > 1)) {
  			if (l->l_wchan != NULL)
  				unsleep(l);
  			l->l_stat = LSONPROC;
***************
*** 555,561 ****
  	 * wait4() and _lwp_wait() from wedging an exiting process
  	 * would be preferred.
  	 */
! 	if (catch && ((p->p_flag & P_WEXIT) && exiterr))
  		return (EINTR);
  	return (0);
  }
--- 567,573 ----
  	 * wait4() and _lwp_wait() from wedging an exiting process
  	 * would be preferred.
  	 */
! 	if (catch && ((p->p_flag & P_WEXIT) && p->p_nlwps > 1 && exiterr))
  		return (EINTR);
  	return (0);
  }