delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-apps/2001/12/19/16:24:15

Mailing-List: contact cygwin-apps-help AT cygwin DOT com; run by ezmlm
Sender: cygwin-apps-owner AT cygwin DOT com
List-Subscribe: <mailto:cygwin-apps-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin-apps/>
List-Post: <mailto:cygwin-apps AT cygwin DOT com>
List-Help: <mailto:cygwin-apps-help AT cygwin DOT com>, <http://sources.redhat.com/lists.html#faqs>
Delivered-To: mailing list cygwin-apps AT cygwin DOT com
Message-ID: <3C210559.8E035D75@yahoo.com>
Date: Wed, 19 Dec 2001 16:23:37 -0500
From: Earnie Boyd <earnie_boyd AT yahoo DOT com>
Reply-To: CA List <Cygwin-Apps AT cygwin DOT com>
X-Mailer: Mozilla 4.77 [en] (WinNT; U)
X-Accept-Language: en
MIME-Version: 1.0
To: Michael Rumpf <michael AT rumpfonline DOT de>
CC: cygwin-apps AT cygwin DOT com, CA List <Cygwin-Apps AT cygwin DOT com>
Subject: Re: bash/cmd and CTRL-C problem...
References: <008101c188d2$b95e76d0$c51811ac AT brokat DOT de>

Wrong list.  This post belongs on cygwin AT cygwin DOT com.  Before posting to
this or other lists please review the list functions at
http://cygwin.com/lists.html .

Earnie.

Michael Rumpf wrote:
> 
> 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.
> Any hint would be greatly appreciated...
> 
> Michael
> 
> PS: I just downloaded the latest stable version 1.3.6 today...

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

- Raw text -


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