lkml.org 
[lkml]   [2000]   [Oct]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: 2.4.0-test6 network socket problems
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/

\
 
 \ /
  Last update: 2005-03-22 12:41    [W:0.042 / U:1.480 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site