From: mquinson Date: Thu, 6 Jul 2006 17:38:30 +0000 (+0000) Subject: Also display the backtrace on Ctrl-C (use Ctrl-C Ctrl-C to quit) X-Git-Tag: v3.3~2864 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/63c620994dde3ca6d580fef1351497ca17b5c401?hp=1686f70fdc6caf53c2fad8d39aced56a6743cd25 Also display the backtrace on Ctrl-C (use Ctrl-C Ctrl-C to quit) git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@2494 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/src/gras/gras.c b/src/gras/gras.c index 576f2d70a1..28a5ead0d7 100644 --- a/src/gras/gras.c +++ b/src/gras/gras.c @@ -27,6 +27,17 @@ static void gras_sigusr_handler(int sig) { INFO0("SIGUSR1 received. Display the backtrace"); xbt_backtrace_display(); } + +static void gras_sigint_handler(int sig) { + static double lastone = 0; + if (lastone == 0 || gras_os_time() - lastone > 5) { + lastone = gras_os_time(); + xbt_backtrace_display(); + fprintf(stderr,"\nBacktrace displayed because Ctrl-C was pressed. Press again (within 5 sec) to abort the process.\n"); + } else { + exit(1); + } +} #endif void gras_init(int *argc,char **argv) { @@ -59,6 +70,7 @@ void gras_init(int *argc,char **argv) { gras_datadesc_init(); #if defined(HAVE_SIGNAL) && defined(HAVE_SIGNAL_H) signal(SIGUSR1,gras_sigusr_handler); + signal(SIGINT,gras_sigint_handler); #endif } }