delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/02/24/13:27:19

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
Message-ID: <031501c2dc32$8d430390$c67486d9@webdev>
From: "Elfyn McBratney" <elfyn-cygwin AT exposure DOT org DOT uk>
To: "cygwin" <cygwin AT cygwin DOT com>,
"Eric Mandel" <eric AT head-cfa DOT cfa DOT harvard DOT edu>
References: <200302241757 DOT h1OHvQN16044 AT head-cfa DOT cfa DOT harvard DOT edu>
Subject: Re: connect() not interrupted by sigalrm?
Date: Mon, 24 Feb 2003 18:28:33 -0000
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019