This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: connect() not interrupted by sigalrm?


> I have an application that calls alarm() before connect() in order to
> prevent connect() from hanging if the host is down or non-existent.
> When alarm() goes off, it sends the SIGALRM signal, which interrupts
> the connect() system call.  This works under Linux, Solaris, OSF, and
> Mac OS X, but apparently not under Cygwin. As shown in the appended
> code, the alarm does go off and can trigger an associated alarm
> function, but the connect() system call is not interrupted.

Cockpit error. You left out a few headers.
--- connect_test.c.orig 2003-02-24 18:25:34.000000000 +0000
+++ connect_test.c      2003-02-24 18:18:42.000000000 +0000
@@ -7,8 +7,11 @@
 #include <stdlib.h>
 #include <signal.h>
+#include <string.h>
 #include <sys/types.h>
 #include <sys/time.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
+#include <unistd.h>
+#include <arpa/inet.h>

 /* the domain exists but not the machine */

- string.h is needed for memset()
- unistd.h is needed for alarm()
- arpa/inet.h is needed for inet_addr()

After that it works fine.


Regards,

Elfyn McBratney
elfyn at exposure dot org dot uk
www.exposure.org.uk


--
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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]