* 1.3.11: accept ist not interrupted by a signal
@ 2002-06-28 7:53 Thomas Pfaff
2002-06-28 10:27 ` Christopher Faylor
0 siblings, 1 reply; 5+ messages in thread
From: Thomas Pfaff @ 2002-06-28 7:53 UTC (permalink / raw)
To: cygwin
I am a bit confused about the current signal handling in a blocking
accept call (i have not checked other system calls yet)
If the process is blocked it is not interrupted by a signal. It first
waits until a connection is made and call the signal handler afterwards.
Is this by design ? IMHO it should call the signal handler and return
EINTR.
I have attached a small testprogram.
When i press CTRL-C during accept the program will stay until i make a
connection, then the signal handler is called. If i press CTRL-C twice the
process starts to eat CPU time.
Thomas
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <signal.h>
#define MY_PORT (5678)
static void sig_handler( int signo );
int main( void )
{
int listen_sock;
int conn_sock;
struct sockaddr_in s_local;
struct sockaddr_in from;
int fromlen = sizeof( from );
signal( SIGTERM, sig_handler );
signal( SIGINT, sig_handler );
s_local.sin_family = AF_INET;
s_local.sin_addr.s_addr = INADDR_ANY;
s_local.sin_port = htons( MY_PORT );
listen_sock = socket( AF_INET, SOCK_STREAM, 0 );
bind( listen_sock, (struct sockaddr*) &s_local, sizeof( s_local ) );
listen( listen_sock, 1 );
conn_sock = accept( listen_sock, (struct sockaddr*) &from, &fromlen);
if(conn_sock >= 0)
{
printf( "Got connection\n");
close( conn_sock );
}
close( listen_sock );
return 0;
}
static void sig_handler( int signo )
{
printf("terminated\n");
exit( 0 );
}
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
^ permalink raw reply [flat|nested] 5+ messages in thread
* 1.3.11: accept ist not interrupted by a signal
@ 2002-10-25 6:48 Franck Leray
2002-10-28 4:28 ` Thomas Pfaff
0 siblings, 1 reply; 5+ messages in thread
From: Franck Leray @ 2002-10-25 6:48 UTC (permalink / raw)
To: cygwin
Hi all,
A process waiting for clients on a 'accept' statement becomes mad (eating cpu) when it receives a signal.
Not on UNIX platform.
See the message of Christopher Faylor (28 jun 2002) '1.3.11: accept ist not interrupted by a signal' for an example.
I don't want to use a non-blocking socket.
Is there an other solution ?
Is it a bug ?
Franck.
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: 1.3.11: accept ist not interrupted by a signal
@ 2002-10-25 8:28 lhall
0 siblings, 0 replies; 5+ messages in thread
From: lhall @ 2002-10-25 8:28 UTC (permalink / raw)
To: franck.leray, cygwin
Well, you could try the latest released Cygwin DLL (1.3.14-1) or a snapshot.
If you don't have better luck, I think you can assume Chris's response is
still valid. Oh and if that's is the case, I'm obligated to add "Patches
gratefully accepted". :-)
Sorry, I don't know of another option.
HTH,
Larry
Original Message:
-----------------
From: Franck Leray franck.leray@cheops.fr
Date: Fri, 25 Oct 2002 15:17:56 +0200
To: cygwin@cygwin.com
Subject: 1.3.11: accept ist not interrupted by a signal
Hi all,
A process waiting for clients on a 'accept' statement becomes mad (eating
cpu) when it receives a signal.
Not on UNIX platform.
See the message of Christopher Faylor (28 jun 2002) '1.3.11: accept ist not
interrupted by a signal' for an example.
I don't want to use a non-blocking socket.
Is there an other solution ?
Is it a bug ?
Franck.
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
--------------------------------------------------------------------
mail2web - Check your email from the web at
http://mail2web.com/ .
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2002-10-28 8:02 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-28 7:53 1.3.11: accept ist not interrupted by a signal Thomas Pfaff
2002-06-28 10:27 ` Christopher Faylor
2002-10-25 6:48 Franck Leray
2002-10-28 4:28 ` Thomas Pfaff
2002-10-25 8:28 lhall
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 read-only IMAP folder(s) and NNTP newsgroup(s).