GNUPG-1-9-BRANCH gnupg/common (ChangeLog signal.c)

cvs user wk cvs at cvs.gnupg.org
Fri May 13 14:18:44 CEST 2005


    Date: Friday, May 13, 2005 @ 14:37:52
  Author: wk
    Path: /cvs/gnupg/gnupg/common
     Tag: GNUPG-1-9-BRANCH

Modified: ChangeLog signal.c

(got_fatal_signal): Print the signal number if we can't
get a name for it.
(get_signal_name): Return NULL if no name is available.


-----------+
 ChangeLog |    6 ++++++
 signal.c  |   39 +++++++++++++++++++++++++++++++++------
 2 files changed, 39 insertions(+), 6 deletions(-)


Index: gnupg/common/ChangeLog
diff -u gnupg/common/ChangeLog:1.30.2.48 gnupg/common/ChangeLog:1.30.2.49
--- gnupg/common/ChangeLog:1.30.2.48	Mon Apr 18 12:44:45 2005
+++ gnupg/common/ChangeLog	Fri May 13 14:37:52 2005
@@ -1,3 +1,9 @@
+2005-05-13  Werner Koch  <wk at g10code.com>
+
+	* signal.c (got_fatal_signal): Print the signal number if we can't
+	get a name for it.
+	(get_signal_name): Return NULL if no name is available.
+
 2005-04-17  Werner Koch  <wk at g10code.com>
 
 	* sexputil.c (cmp_simple_canon_sexp): New.
Index: gnupg/common/signal.c
diff -u gnupg/common/signal.c:1.2.2.1 gnupg/common/signal.c:1.2.2.2
--- gnupg/common/signal.c:1.2.2.1	Tue Dec 21 11:03:00 2004
+++ gnupg/common/signal.c	Fri May 13 14:37:52 2005
@@ -1,5 +1,6 @@
 /* signal.c - signal handling
- * Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+ * Copyright (C) 1998, 1999, 2000, 2001, 2002,
+ *               2005 Free Software Foundation, Inc.
  *
  * This file is part of GnuPG.
  *
@@ -73,10 +74,12 @@
 static const char *
 get_signal_name( int signum )
 {
+  /* Note that we can't use strsignal(), because it is not
+     reentrant. */
 #if defined(SYS_SIGLIST_DECLARED) && defined(NSIG)
   return (signum >= 0 && signum < NSIG) ? sys_siglist[signum] : "?";
 #else
-  return "some signal";
+  return NULL;
 #endif
 }
 #endif /*!HAVE_DOSISH_SYSTEM*/
@@ -93,19 +96,43 @@
 
   if (cleanup_fnc)
     cleanup_fnc ();
-  /* better don't translate these messages */
+  /* Better don't translate these messages. */
   write (2, "\n", 1 );
   s = log_get_prefix (NULL);
   if (s)
     write(2, s, strlen (s));
   write (2, ": ", 2 );
   s = get_signal_name(sig);
-  write (2, s, strlen(s) );
+  if (s)
+    write (2, s, strlen(s) );
+  else
+    {
+      /* We are in a signal handler so we can't use any kind of printf
+         even not sprintf.  USe a straightforward algorithm. */
+      write (2, "signal ", 7 );
+      if (sig < 0 || sig >= 100000)
+        write (2, "?", 1);
+      else 
+        {
+          int i, any=0;
+
+          for (i=10000; i; i /= 10)
+            {
+              if (sig >= i || ((any || i==1) && !(sig/i)))
+                {
+                  write (2, "0123456789"+(sig/i), 1);
+                  if ((sig/i))
+                    any = 1;
+                  sig %= i;
+                }
+            }
+        }
+    }
   write (2, " caught ... exiting\n", 20);
   
-  /* reset action to default action and raise signal again */
+  /* Reset action to default action and raise signal again */
   init_one_signal (sig, SIG_DFL, 0);
-  /* fixme: remove_lockfiles ();*/
+  /* Fixme: remove_lockfiles ();*/
 #ifdef __riscos__
   close_fds ();
 #endif /* __riscos__ */




More information about the Gnupg-commits mailing list