[PATCH v4 13/16] Log safely in fatal signal handler

Chase Douglas chase.douglas at canonical.com
Mon May 14 14:14:34 PDT 2012


While we probably don't need to be signal safe here since we will never
return to the normal context, the logging signal context check will
cause unsafe logging to be unhandled. Using signal safe logging here
resolves the issue.

Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 os/osinit.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/os/osinit.c b/os/osinit.c
index e2a2208..16e2c2f 100644
--- a/os/osinit.c
+++ b/os/osinit.c
@@ -113,7 +113,7 @@ OsSigHandler(int signo)
     const char *dlerr = dlerror();
 
     if (dlerr) {
-        LogMessage(X_ERROR, "Dynamic loader error: %s\n", dlerr);
+        LogMessageVerbSigSafe(X_ERROR, 1, "Dynamic loader error: %s\n", dlerr);
     }
 #endif                          /* RTLD_DI_SETSIGNAL */
 
@@ -129,8 +129,8 @@ OsSigHandler(int signo)
 
 #ifdef SA_SIGINFO
     if (sip->si_code == SI_USER) {
-        ErrorF("Recieved signal %d sent by process %ld, uid %ld\n",
-               signo, (long) sip->si_pid, (long) sip->si_uid);
+        ErrorSigSafe("Recieved signal %u sent by process %u, uid %u\n", signo,
+                     sip->si_pid, sip->si_uid);
     }
     else {
         switch (signo) {
@@ -138,7 +138,7 @@ OsSigHandler(int signo)
         case SIGBUS:
         case SIGILL:
         case SIGFPE:
-            ErrorF("%s at address %p\n", strsignal(signo), sip->si_addr);
+            ErrorSigSafe("%s at address %p\n", strsignal(signo), sip->si_addr);
         }
     }
 #endif
-- 
1.7.9.5



More information about the xorg-devel mailing list