linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* select: Interrupted system call
@ 2002-04-27 15:04 Gerald Waugh
  2002-04-27 15:28 ` Glynn Clements
       [not found] ` <200204271602.g3RG24F07174@fsn3.frontstreetnetworks.com>
  0 siblings, 2 replies; 4+ messages in thread
From: Gerald Waugh @ 2002-04-27 15:04 UTC (permalink / raw)
  To: linux-c-programming@vger.kernel.org


I am attempting to run a program that manages several tcp/ip connections
It runs for a while then I get the subject error, also below
select: Interrupted system call
I think it may be because I am not handling any signals.
How do I fix it? Asn which signals should I be catching?
TIA

-- 
Gerald Waugh : Registered Linux user # 255245
http://www.frontstreetnetworks.com
Front Street Networks LLC - ph. 203.785.0699
229 Front Street, Ste. #C, New Haven, CT, United States of America
11:01am up 36 days, 18:28, 3 users, load average: 1.09, 1.18, 1.14

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: select: Interrupted system call
  2002-04-27 15:04 select: Interrupted system call Gerald Waugh
@ 2002-04-27 15:28 ` Glynn Clements
       [not found] ` <200204271602.g3RG24F07174@fsn3.frontstreetnetworks.com>
  1 sibling, 0 replies; 4+ messages in thread
From: Glynn Clements @ 2002-04-27 15:28 UTC (permalink / raw)
  To: Gerald Waugh; +Cc: linux-c-programming@vger.kernel.org


Gerald Waugh wrote:

> I am attempting to run a program that manages several tcp/ip connections
> It runs for a while then I get the subject error, also below
> select: Interrupted system call
> I think it may be because I am not handling any signals.

select() returns EINTR if a signal is caught and handled. If a signal
is caught but not handled, it will either do nothing, or terminate the
process, depending upon the signal.

> How do I fix it?

If select() indicates an error, check whether it is EINTR. If it is,
ignore it. Alternatively, you can block the signal (with sigprocmask())
for the duration of the call to select().

-- 
Glynn Clements <glynn.clements@virgin.net>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: select: Interrupted system call
       [not found]   ` <15562.64140.625327.285565@cerise.nosuchdomain.co.uk>
@ 2002-04-27 20:37     ` Gerald Waugh
  2002-04-27 23:20       ` Glynn Clements
  0 siblings, 1 reply; 4+ messages in thread
From: Gerald Waugh @ 2002-04-27 20:37 UTC (permalink / raw)
  To: linux-c-programming@vger.kernel.org

On Saturday 27 April 2002 03:22 pm, Glynn Clements wrote:
> Gerald Waugh wrote:
> +	#include <errno.h>
>
>            rdsocks = select(hs+1, &socks, (fd_set *) 0,
>             (fd_set *) 0, &timeout);
>
> -          if (rdsocks < 0) {
> +          if (rdsocks < 0 && errno != EINTR) {
>
>                    perror("select");
>                    continue;
>                    //  exit(EXIT_FAILURE);
>            }
>
> > I commented out the exit(EXIT_FAILURE); and added continue;
> > but I still get   " select: Interrupted system call ", it keeps running
> > and managing the connections...
> > Seems like I should be able to find out whats causing it,
> > Interrupted system call   Does not seem to tell me much.
> You should handle this case rather than trying to prevent it.
>
> Prevention is fragile; if the program is subsequently changed to catch
> a new signal (possibly via a library function), the problem will
> re-appear.
>
> Handling this case will ensure that the program is robust. Terminating
> due to transient errors isn't a good idea.

I was testing to see if I could keep it going, I did similar to your 
suggestion:
Only I did  if (rdsocks < 0 && rdsocks != EINTR)  {
And I was still getting  a printout of  " select: Interrupted system call "
Now I'll try 
if (rdsocks < 0 && errno != EINTR) {

I would really like to know why select()
gets that  Interrupted system call


-- 
Gerald Waugh : Registered Linux user # 255245
http://www.frontstreetnetworks.com
Front Street Networks LLC - ph. 203.785.0699
229 Front Street, Ste. #C, New Haven, CT, United States of America
4:32pm up 36 days, 23:59, 3 users, load average: 0.80, 1.14, 1.27

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: select: Interrupted system call
  2002-04-27 20:37     ` Gerald Waugh
@ 2002-04-27 23:20       ` Glynn Clements
  0 siblings, 0 replies; 4+ messages in thread
From: Glynn Clements @ 2002-04-27 23:20 UTC (permalink / raw)
  To: Gerald Waugh; +Cc: linux-c-programming@vger.kernel.org


Gerald Waugh wrote:

> I would really like to know why select()
> gets that  Interrupted system call

If you have "strace", that should show which signal is being caught.

-- 
Glynn Clements <glynn.clements@virgin.net>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-04-27 23:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-04-27 15:04 select: Interrupted system call Gerald Waugh
2002-04-27 15:28 ` Glynn Clements
     [not found] ` <200204271602.g3RG24F07174@fsn3.frontstreetnetworks.com>
     [not found]   ` <15562.64140.625327.285565@cerise.nosuchdomain.co.uk>
2002-04-27 20:37     ` Gerald Waugh
2002-04-27 23:20       ` Glynn Clements

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).