public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* bash/cmd CTRL-C problem...
@ 2001-12-19 23:48 Michael Rumpf
  2001-12-20  1:28 ` Michael Rumpf
  0 siblings, 1 reply; 35+ messages in thread
From: Michael Rumpf @ 2001-12-19 23:48 UTC (permalink / raw)
  To: cygwin

Hi,

I'm new to the list and I don't know if this problem is already solved, but
I couldn't find a hint neither on the archives nor on the FAQ or somewhere
else on the net.

My problem is related to bash/cmd and signal handling.
In my app I installed a signal handler for SIGINT. The app is going into a
wait loop and waiting for the exit flag from the signal handler to be set.

When pressing CTRL-C in the windows cmd shell the application continues
normally after the signal handler has been caught. Under bash the signal
handler is also correctly called, but after that the app is exiting
immediatly, i.e. not continuing with the code.
Here is the source:

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

bool loop = true;

extern "C" void signalHandler(int sig)
{
   switch( sig )
   {
      case SIGINT:  // == 2
         printf("SIGINT=%d\n",sig);
         break;
      default:
         printf("default=%d\n",sig);
         break;
   };
   loop=false;
}

int main(int argc, char* argv[])
{
   if (signal( SIGINT , signalHandler ) == SIG_ERR)
      return -1;
   printf("### ctrlbreak: Waiting now...\n");
   while(loop)
     Sleep ((DWORD) 1000) ;
   printf("### ctrlbreak: Finished waiting now...\n");
   return 0;
}
////////////////////////////////////////////////////////////////////////////
/////////////////

Here the the output of the app under Win2K/bash:
// bash                2.05a-2
$ ./ctrlbreak.exe
### ctrlbreak: Waiting now...
SIGINT=2


// GNU bash, version 2.02.1(2)-release (i586-pc-cygwin32) B20.1
bash-2.02$ ./ctrlbreak
### ctrlbreak: Waiting now...
SIGINT=2

// cmd.exe Win2k SP2
### ctrlbreak: Waiting now...
SIGINT=2
### ctrlbreak: Finished waiting now...


You can see that under the cmd shell the text "Finished waiting now..." is
printed which does not come out under the bash. The app is not linked
against any cygwin library. It is a plain VC++ console application. But when
I compile with gcc from the cygwin package I have the same result.
Any hint would be greatly appreciated...

Michael

PS: I just downloaded the latest stable version 1.3.6 today...



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

^ permalink raw reply	[flat|nested] 35+ messages in thread

end of thread, other threads:[~2002-01-10 15:53 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-12-19 23:48 bash/cmd CTRL-C problem Michael Rumpf
2001-12-20  1:28 ` Michael Rumpf
2001-12-21  2:17   ` Michael Rumpf
2001-12-21  7:27     ` Corinna Vinschen
2001-12-21  8:46       ` Michael Rumpf
2002-01-04  3:51     ` Michael Rumpf
2002-01-04  9:04       ` Christopher Faylor
2002-01-07  0:46         ` Michael Rumpf
2002-01-07  1:10           ` Robert Collins
2002-01-07  1:58             ` Michael Rumpf
2002-01-07  2:30               ` Robert Collins
2002-01-07  2:56                 ` Michael Rumpf
2002-01-07  5:15                   ` CGF: please review my logic " Robert Collins
2002-01-07  6:18                     ` Michael Rumpf
2002-01-07  8:50                     ` CGF: " Christopher Faylor
2002-01-07 15:00                       ` Robert Collins
2002-01-07 15:45                         ` Christopher Faylor
2002-01-07 16:15                           ` Robert Collins
2002-01-07 16:21                             ` Christopher Faylor
2002-01-07 16:43                               ` Robert Collins
2002-01-07 23:00                                 ` Robert Collins
2002-01-08  8:19                                   ` Christopher Faylor
2002-01-08 14:16                                     ` Robert Collins
2002-01-08 16:39                                       ` Christopher Faylor
2002-01-08 16:43                                         ` Robert Collins
2002-01-08 16:55                                           ` Christopher Faylor
2002-01-08 16:57                                             ` Robert Collins
2002-01-08 17:13                                               ` Christopher Faylor
2002-01-08 17:16                                                 ` Robert Collins
2002-01-09 18:46                                                   ` Christopher Faylor
2002-01-09 19:42                                                     ` Christopher Faylor
2002-01-09 23:59                                                     ` Robert Collins
2002-01-10  7:53                                                       ` Christopher Faylor
2002-01-08 17:46                                                 ` Charles Wilson
     [not found]                                   ` <027401c19855$68842f60$c51811ac@brokat.de>
     [not found]                                     ` <03a901c1989b$69c8e190$0200a8c0@lifelesswks>
2002-01-09  0:14                                       ` Michael Rumpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).