Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com> List-Archive: <http://sources.redhat.com/ml/cygwin/> List-Post: <mailto:cygwin AT cygwin DOT com> List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs> Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com X-Authentication-Warning: atacama.four-d.de: mail set sender to <tpfaff AT gmx DOT net> using -f Date: Fri, 28 Jun 2002 14:34:16 +0200 (=?ISO-8859-1?Q?Westeurop=E4ische_Sommerzeit?=) From: Thomas Pfaff <tpfaff AT gmx DOT net> To: cygwin AT cygwin DOT com Subject: 1.3.11: accept ist not interrupted by a signal Message-ID: <Pine.WNT.4.44.0206281405210.269-100000@algeria.intern.net> X-X-Sender: pfaff AT antarctica DOT intern DOT net MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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/