From: cgf AT bbc DOT com (Christopher Faylor) Subject: Re: Signals in b19 - please help 8 Mar 1998 16:27:42 -0800 Message-ID: References: Reply-To: cgf AT bbc DOT com To: gnu-win32 AT cygnus DOT com In article , Ian Collins wrote: >Can someone help me. I have a problem with signal handling (notably >alarm calls) on b19. The problem was also around in b18, but I was >hoping.... > >The problem can be shown in an example program, as follows, > >#include >#include > >/* > Designed to test the alarm calls. > */ >main() >{ > int ch; > extern void handler(); > while (1) { > printf("Setting alarm\n"); > if (signal(SIGALRM, handler) == SIG_ERR) return -1; > alarm(5); > printf("Set alarm. Getting input\n"); > ch = getchar(); > printf("getchar returned %d\n", ch); > } >} > >void handler() >{ > printf("In handler. I want getchar to return now like Unix does\n"); >} > >When this program is run on most Unix machines (OK, AIX needs kicking to >get it to work), the getchar will return after the timeout occurs. >What we see however is that after the timeout handler is called, the >getchar does not return, it still waits for a character to be input. > >Is there any way I can get getchar to interrupt and return? This is a >showstopper for me ar present. Can anyone help! You've hit one of the biggest problems in cygwin but I don't know of any way around this behavior due to Win32 behavior. It is not possible to interrupt a blocking read in Win32. That's what you're expecting in the code above. I wish there was some way to do this in a way that worked on all implementations of Win32 but I'm not aware of any. Sorry. -- http://www.bbc.com/ cgf AT bbc DOT com "Strange how unreal VMS=>UNIX Solutions Boston Business Computing the real can be." - For help on using this list (especially unsubscribing), send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".