Re: 2.4.0-test6 network socket problems

From: Richard B. Johnson (root@chaos.analogic.com)
Date: Fri Oct 13 2000 - 16:13:59 EST


On Fri, 13 Oct 2000, J. Scott Kasten wrote:

> I've found the problem. This type of loop does not work:
>
> do {
> alarm(t);
> read(fd);
> if (EINT)
> exception();
> else
> alarm(0);
> } while (data);
>
> There are some semantics here that differ from other *nix where this
> works. The read() won't come out when the alarm comes, and the socket
> will effectively become broken.
>
> Instead, it appears that I needed to use select(), which probably would
> have been better in the first place anyway.
>
> Thanks to anyone that took the time to look at this.
>

You can certainly use select() and it's 'better' and more useful.
However, the problem is the default nature of the way signal() in the 'C'
runtime library sets up the handler.

You should use sigaction() without the SA_RESTART flag. This lets
a signal unblock a system call, the resulting errno being EINTER.

Cheers,
Dick Johnson

Penguin : Linux version 2.2.17 on an i686 machine (801.18 BogoMips).

"Memory is like gasoline. You use it up when you are running. Of
course you get it all back when you reboot..."; Actual explanation
obtained from the Micro$oft help desk.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun Oct 15 2000 - 21:00:26 EST