X-Recipient: archive-cygwin@delorie.com
X-Spam-Check-By: sourceware.org
From: "greg" <gregorys@mips.com>
To: <cygwin@cygwin.com>
Cc: <"macro@mips.com"@delorie.com>
Subject: SIGINT handler not called during blocking pipe read
Date: Fri, 12 Oct 2007 10:26:25 -0400
Message-ID: <PJEDIAJFFCEEKLEEKMBCCEBICMAA.gregorys@mips.com>
MIME-Version: 1.0
Content-Type: text/plain; 	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0)
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com

I'm trying to use a Cygwin-linked program as a subprocess in Eclipse.
As spawned in this environment, if a SIGINT is sent to the process when
it is blocked reading from stdin (connected to a pipe in this case), the
SIGINT handler is not being called.

In an attempt to reduce the scenario to its essentials, I was able to
replicate the symptoms with a minimal outside-of-Eclipse scenario below.

Is this expected behavior with respect to SIGINT during a pipe read?

--

/*  
 *  File name: catchsigint.c
 *
 *  A pared-down example illustrating SIGINT handler not being
 *  called when SIGINT received while process is blocked waiting
 *  for a read from pipe.
 *  
 *  The symptoms are seen with Cygwin 1.5.24-2 as well as earler
 *  versions, on Windows XP+SP2 and Win2K.
 *  
 *  To build:  gcc -o catchsigint.exe catchsigint.c
 *  
 *  Steps to reproduce symptoms:
 *  
 *  1) From the Windows Start menu, open a native Windows command
 *  prompt.
 *
 *  2) Launch this example program (catchsigint.exe) from the native 
 *  Windows command prompt, with stdin coming from a pipe.
 *  
 *  C:\temp>cat | catchsigint
 *  
 *  3) As the catchsigint process is blocked waiting for input from
 *  the pipe, send SIGINT to the catchsigint process via 
 *  "kill -SIGINT pid" from a Cygwin shell.
 *
 */

#include <stdio.h>
#include <signal.h>

void handler(int sig) {
   printf("SIGINT caught\n");
   exit(-1);
}

int main() {
   signal(SIGINT, handler);
   /*  The following sets up a blocking read,
       then we'll send a SIGINT from outside */
   getchar();  
   return 0;
}



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

