Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
ignore another generated file
[simgrid.git] / tools / tesh / signal.c
index a6d26b8..204d52a 100644 (file)
@@ -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. */
 #include <signal.h>
 
 typedef struct s_signal_entry {
-  const charname;
+  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 bprintf("SIG UNKNOWN (%d)", got);
+  return bprintf("SIG UNKNOWN (%u)", got);
 }