[comp.bugs.sys5] Bug/Problems with SVR3.2 ldterm streams module

linwood@b11.ingr.com (Linwood Varney) (08/20/89)

When entering RAW mode, depending on the setting of VMIN, ldterm
sends certain options to the stream head.  It only sends these options
when entering RAW mode from CANON mode.  If the value of VMIN is
changed to 0, without first going back to CANON mode, a read, which
should return immediately, will pend forever, because the stream head
has not been informed of the new settings.

The following change in ldtermioc() seems to fix the problem.  It
forces ldterm to send new options to the stream head if the value of
VMIN changes while still in RAW mode.


		if (CANON_MODE && !( cb->c_lflag & ICANON))
			tp->lmode_flg = B_RAW;
		else if (RAW_MODE && ( cb->c_lflag & ICANON ))
			tp->lmode_flg = B_CANON;
	/* ---  Begin fix  --- */
		else if (V_MIN != cb->c_cc[VMIN] && (!V_MIN || !cb->c_cc[VMIN]))
			tp->lmode_flg = B_RAW;
	/* ---  End of fix  --- */
		else 
			tp->lmode_flg = 0;	/* no change. */


After applying this change, and running my program, my machine
promptly gave me a bizarre PANIC.  After looking at the crash dump,
I discovered this in ldtermosrv():


	if ( RAW_MODE && (char) V_MIN == 0 ) { /* handle only vmin = 0 case */
		x=spltty();
		.
		.
		.		
	}
	splx(x);


If you do not go through the if statement, your spl is set to some random
value.  The fix is to simply put the splx(x) inside the if statment.

	- Linwood Varney		Network Communications
	  linwood@ingr.com		Intergraph Corp.
	..!uunet!ingr!linwood		Huntsville, AL