Console app and CTRL+C


#1

Is there a way for a JUCE based console app on linux not STOP when CTRL+C is pressed, this is what happens everytime i press ctrl+c when my app is running

[root@rancho:/sphinctour/devel/envi/envimond/Source]# envimond
JUCE v3.0.0
JUCE Assertion failure in EnviLog.h:27
Envi: EnviLog::ctor
Envi: EnviApplication::ctor
Envi: EnviHTTP::ctor
Envi: EnviDB::run
Envi: EnviApplication::runDispatchLoop running
^C
[2]+  Stopped                 envimond

I'd like to catch the CTRL+C with a signal handler (SIGINT) but i can't, it looks like the app just goes into background (job control in bash), i can bring it back with "fg" and then pressing CTRL+C again causes it to actualy die:

[root@rancho:/sphinctour/devel/envi/envimond/Source]# fg
envimond
^CEnvi: caught signal 2
*** Leaked objects detected: 1 instance(s) of class EnviDSDHT11
JUCE Assertion failure in juce_LeakedObjectDetector.h:95
*** Leaked objects detected: 2 instance(s) of class EnviData
JUCE Assertion failure in juce_LeakedObjectDetector.h:95
*** Leaked objects detected: 1 instance(s) of class EnviDSBMP085

I registered some signal handlers to see if any signal is getting to the app when i press CTRL+C the first time but no luck

void signalCallback(int signum)
{
  printf ("Envi: caught signal %d\n", signum);
  exit (1);
}

int main(void)

{

        signal (SIGINT, signalCallback);
        signal (SIGHUP, signalCallback);
        signal (SIGKILL, signalCallback);
        signal (SIGTERM, signalCallback);
        signal (SIGSTOP, signalCallback);
        signal (SIGSEGV, signalCallback);
        signal (SIGQUIT, signalCallback);
        signal (SIGALRM, signalCallback);
        signal (SIGUSR1, signalCallback);
        signal (SIGABRT, signalCallback);
        signal (SIGPIPE, signalCallback);
        signal (SIGTRAP, signalCallback);

}

It makes debugging very hard if i can't just stop the app.


#2

(from memory, since I recall having that sort of issue in the past) I think this happens only when building in debug mode, not in release mode, and is related to juce setting a breakpoint for the debugger in jassert()