serial on lombard

Momchil Velikov velco at fadata.bg
Fri Oct 15 00:53:43 EST 1999


Benjamin Herrenschmidt wrote:
> --- minicom-1.82.orig/src/main.c        Thu Aug 27 00:54:16 1998
> +++ minicom-1.82/src/main.c     Thu Oct 14 16:20:00 1999
> @@ -158,7 +158,7 @@
>    if (setjmp(albuf) == 0) {
>         portfd = -1;
>         signal(SIGALRM, get_alrm);
> -       alarm(2);
> +       alarm(4);
>  #if defined(O_NDELAY) && defined(F_SETFL)
>         portfd = open(dial_tty, O_RDWR|O_NDELAY);
>         if (portfd >= 0){

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,
-velco

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





More information about the Linuxppc-dev mailing list