X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/201c29ab62c93305b5cdc3e973ccee3c59f65c07..6d14c1b85abceee6c22915a6d8e8c4d49e8f3b03:/tools/tesh/signal.c diff --git a/tools/tesh/signal.c b/tools/tesh/signal.c index b70ce5b615..204d52a90b 100644 --- a/tools/tesh/signal.c +++ b/tools/tesh/signal.c @@ -1,9 +1,7 @@ -/* $Id$ */ - /* signal -- what TESH needs to know about signals */ -/* Copyright (c) 2007 Martin Quinson. */ -/* All rights reserved. */ +/* Copyright (c) 2007-2010, 2012-2014. The SimGrid Team. + * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -12,55 +10,56 @@ #include typedef struct s_signal_entry { - const char* name; + const char *name; int number; -} s_signal_entry_t,* signal_entry_t; +} s_signal_entry_t, *signal_entry_t; static const s_signal_entry_t signals[] = { - {"SIGHUP" ,SIGHUP}, - {"SIGINT" ,SIGINT}, - {"SIGQUIT" ,SIGQUIT}, - {"SIGILL" ,SIGILL}, - {"SIGTRAP" ,SIGTRAP}, - {"SIGABRT" ,SIGABRT}, - {"SIGFPE" ,SIGFPE}, - {"SIGKILL" ,SIGKILL}, - {"SIGBUS" ,SIGBUS}, - {"SIGSEGV" ,SIGSEGV}, - {"SIGSYS" ,SIGSYS}, - {"SIGPIPE" ,SIGPIPE}, - {"SIGALRM" ,SIGALRM}, - {"SIGTERM" ,SIGTERM}, - {"SIGURG" ,SIGURG}, - {"SIGSTOP" ,SIGSTOP}, - {"SIGTSTP" ,SIGTSTP}, - {"SIGCONT" ,SIGCONT}, - {"SIGCHLD" ,SIGCHLD}, - {"SIGTTIN" ,SIGTTIN}, - {"SIGTTOU" ,SIGTTOU}, - {"SIGIO" ,SIGIO}, - {"SIGXCPU" ,SIGXCPU}, - {"SIGXFSZ" ,SIGXFSZ}, - {"SIGVTALRM" ,SIGVTALRM}, - {"SIGPROF" ,SIGPROF}, - {"SIGWINCH" ,SIGWINCH}, - {"SIGUSR1" ,SIGUSR1}, - {"SIGUSR2" ,SIGUSR2}, - {"SIG UNKNOWN" ,-1} + {"SIGHUP", SIGHUP}, + {"SIGINT", SIGINT}, + {"SIGQUIT", SIGQUIT}, + {"SIGILL", SIGILL}, + {"SIGTRAP", SIGTRAP}, + {"SIGABRT", SIGABRT}, + {"SIGFPE", SIGFPE}, + {"SIGKILL", SIGKILL}, + {"SIGBUS", SIGBUS}, + {"SIGSEGV", SIGSEGV}, + {"SIGSYS", SIGSYS}, + {"SIGPIPE", SIGPIPE}, + {"SIGALRM", SIGALRM}, + {"SIGTERM", SIGTERM}, + {"SIGURG", SIGURG}, + {"SIGSTOP", SIGSTOP}, + {"SIGTSTP", SIGTSTP}, + {"SIGCONT", SIGCONT}, + {"SIGCHLD", SIGCHLD}, + {"SIGTTIN", SIGTTIN}, + {"SIGTTOU", SIGTTOU}, + {"SIGIO", SIGIO}, + {"SIGXCPU", SIGXCPU}, + {"SIGXFSZ", SIGXFSZ}, + {"SIGVTALRM", SIGVTALRM}, + {"SIGPROF", SIGPROF}, + {"SIGWINCH", SIGWINCH}, + {"SIGUSR1", SIGUSR1}, + {"SIGUSR2", SIGUSR2}, + {"SIG UNKNOWN", -1} }; -const char* signal_name(unsigned int got, char *expected) { +const char *signal_name(int got, char *expected) +{ int i; /* Make SIGBUS a synonym for SIGSEGV (segfault leads to any of them depending on the system) */ - if((got == SIGBUS) && !strcmp("SIGSEGV",expected)) + if ((got == SIGBUS) && !strcmp("SIGSEGV", expected)) got = SIGSEGV; - - for (i=0; signals[i].number != -1; i++) + + for (i = 0; signals[i].number != -1; i++) if (signals[i].number == got) return (signals[i].name); - return "SIG UNKNOWN"; + return bprintf("SIG UNKNOWN (%u)", got); }