]> git.sur5r.net Git - i3/i3/commitdiff
sighandler: provide gdb with pipe stdin/stdout fds (necessary for gdb < 7.5)
authorMichael Stapelberg <michael@stapelberg.de>
Tue, 11 Sep 2012 10:57:53 +0000 (12:57 +0200)
committerMichael Stapelberg <michael@stapelberg.de>
Tue, 11 Sep 2012 10:57:53 +0000 (12:57 +0200)
src/sighandler.c

index fe8c9f64f6e7f32d41cc9b7abfdafe6f3559066a..5d9878652c2ec80a387b47ea208ae24f0cdc710f 100644 (file)
@@ -62,6 +62,11 @@ static int backtrace(void) {
         return -1;
     } else if (pid_gdb == 0) {
         /* child */
+        int stdin_pipe[2],
+            stdout_pipe[2];
+
+        pipe(stdin_pipe);
+        pipe(stdout_pipe);
 
         /* close standard streams in case i3 is started from a terminal; gdb
          * needs to run without controlling terminal for it to work properly in
@@ -70,6 +75,12 @@ static int backtrace(void) {
         close(STDOUT_FILENO);
         close(STDERR_FILENO);
 
+        /* We provide pipe file descriptors for stdin/stdout because gdb < 7.5
+         * crashes otherwise, see
+         * http://sourceware.org/bugzilla/show_bug.cgi?id=14114 */
+        dup2(stdin_pipe[0], STDIN_FILENO);
+        dup2(stdout_pipe[1], STDOUT_FILENO);
+
         char *pid_s = NULL;
         sasprintf(&pid_s, "%d", pid_parent);