serial on lombard

Momchil Velikov velco at fadata.bg
Fri Oct 15 17:26:54 EST 1999


Michael Schmitz wrote:
> 
> > I think the code should be as follows:
> >    signal( SIGALRM, a_signal_handler_which_just_returns );
> >    alarm(4);
> >    portfd = open( dial_tty, O_RDWR|O_NONBLOCK);
> >    alarm(0);
> >    if( portfd >= 0 ) {
> >       ...
> >
> > In old code (and in the patched one too) there is a race condition
> > between clearing the alarm and signal delivery. A sequence similar
> > to the above one relies only on the return value of open().
> > Regards,
> 
> alarm(0) only clears the timer and won't change the return value of open.
> Watching the strace output closely you will see that the return value of
> open is filled in only after the alarm fired. The macserial open fails to
> check for pending signals after completing the modem powerup wait, and
> can't detect the timeout.

There is no need to change the return value of open(). One should _examine_ it,
and the minicom doesn't do this -- its on the 0-branch of setjmp.
Actually, there is _absolutely_ no need for alarm() -- if you say
O_NONBLOCK, you should not expect to block and you should not try to work
around with some fancy timeouts and stuff. The old code, the proposed patch
and my proposal are simply pointless -- that's to say, they all try
to solve a problem which doesn't exist (and thay fail, of course ;-).

Regards,
-velco

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/





More information about the Linuxppc-dev mailing list