This is the mail archive of the
cygwin
mailing list for the Cygwin project.
SIGINT handler not called during blocking pipe read
- From: "greg" <gregorys at mips dot com>
- To: <cygwin at cygwin dot com>
- Cc: <"macro at mips dot com">
- Date: Fri, 12 Oct 2007 10:26:25 -0400
- Subject: SIGINT handler not called during blocking pipe read
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/