gdb/
[binutils-gdb.git] / gdb / ser-pipe.c
index 77c3a08e9a9850ebecca4910065e30ed4d6ca698..07fe65b14e93c4dd30ce927b975f6ec2d1fbb2b9 100644 (file)
@@ -63,6 +63,7 @@ pipe_open (struct serial *scb, const char *name)
   int pdes[2];
   int err_pdes[2];
   int pid;
+
   if (socketpair (AF_UNIX, SOCK_STREAM, 0, pdes) < 0)
     return -1;
   if (socketpair (AF_UNIX, SOCK_STREAM, 0, err_pdes) < 0)
@@ -98,6 +99,15 @@ pipe_open (struct serial *scb, const char *name)
   /* Child. */
   if (pid == 0)
     {
+      /* We don't want ^c to kill the connection.  */
+#ifdef HAVE_SETSID
+      pid_t sid = setsid ();
+      if (sid == -1)
+       signal (SIGINT, SIG_IGN);
+#else
+      signal (SIGINT, SIG_IGN);
+#endif
+
       /* re-wire pdes[1] to stdin/stdout */
       close (pdes[0]);
       if (pdes[1] != STDOUT_FILENO)
@@ -146,6 +156,7 @@ static void
 pipe_close (struct serial *scb)
 {
   struct pipe_state *state = scb->state;
+
   if (state != NULL)
     {
       int pid = state->pid;
@@ -163,12 +174,11 @@ pipe_close (struct serial *scb)
     }
 }
 
-static struct serial_ops pipe_ops;
-
 void
 _initialize_ser_pipe (void)
 {
   struct serial_ops *ops = XMALLOC (struct serial_ops);
+
   memset (ops, 0, sizeof (struct serial_ops));
   ops->name = "pipe";
   ops->next = 0;