Switch core from strerror to g_strerror
[claws.git] / src / crash.c
index 5f3eaa9924d5b401d66c107169b931443ce76f4a..cb1f1fe30cfcbff9c7bc81df5a5413387783aaf3 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 2002-2012 by the Claws Mail Team
+ * Copyright (C) 2002-2015 by the Claws Mail Team
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -14,7 +14,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * 
+ *
  */
 
 #ifdef HAVE_CONFIG_H
@@ -333,15 +333,20 @@ static void crash_debug(unsigned long crash_pid,
        int choutput[2];
        pid_t pid;
 
-       pipe(choutput);
+       if (pipe(choutput) == -1) {
+               g_print("can't pipe - error %s", g_strerror(errno));
+               return;
+       }
 
        if (0 == (pid = fork())) {
                char *argp[10];
                char **argptr = argp;
                gchar *filespec = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, DEBUGGERRC, NULL);
 
-               setgid(getgid());
-               setuid(getuid());
+               if (setgid(getgid()) != 0)
+                       perror("setgid");
+               if (setuid(getuid()) != 0)
+                       perror("setuid");
 
                /*
                 * setup debugger to attach to crashed claws
@@ -361,7 +366,8 @@ static void crash_debug(unsigned long crash_pid,
                 * redirect output to write end of pipe
                 */
                close(1);
-               dup(choutput[1]);
+               if (dup(choutput[1]) < 0)
+                       perror("dup");
                close(choutput[0]);
                if (-1 == execvp("gdb", argp)) 
                        g_print("error execvp\n");
@@ -535,9 +541,12 @@ static void crash_handler(int sig)
                args[3] = buf;
                args[4] = NULL;
 
-               chdir(claws_get_startup_dir());
-               setgid(getgid());
-               setuid(getuid());
+               if (chdir(claws_get_startup_dir()) != 0)
+                       perror("chdir");
+               if (setgid(getgid()) != 0)
+                       perror("setgid");
+               if (setuid(getuid()) != 0 )
+                       perror("setuid");
                execvp(argv0, args);
        } else {
                waitpid(pid, NULL, 0);