X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gdb%2Fser-pipe.c;h=274883c50b1210a4f86280edd17911c409244e3e;hb=7f502d6c5a69837ad293d942ffa18fc16b8d0e3a;hp=053dcead1e1d898568b1c7d6ba3482575903a88e;hpb=9b254dd1ce46c19dde1dde5b8d1e22e862dfacce;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/ser-pipe.c b/gdb/ser-pipe.c index 053dcead1e..274883c50b 100644 --- a/gdb/ser-pipe.c +++ b/gdb/ser-pipe.c @@ -1,5 +1,6 @@ /* Serial interface for a pipe to a separate program - Copyright (C) 1999, 2000, 2001, 2007, 2008 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2001, 2007, 2008, 2009, 2010 + Free Software Foundation, Inc. Contributed by Cygnus Solutions. @@ -65,7 +66,11 @@ pipe_open (struct serial *scb, const char *name) if (socketpair (AF_UNIX, SOCK_STREAM, 0, pdes) < 0) return -1; if (socketpair (AF_UNIX, SOCK_STREAM, 0, err_pdes) < 0) - return -1; + { + close (pdes[0]); + close (pdes[1]); + return -1; + } /* Create the child process to run the command in. Note that the apparent call to vfork() below *might* actually be a call to @@ -122,6 +127,8 @@ pipe_open (struct serial *scb, const char *name) /* Parent. */ close (pdes[1]); + if (err_pdes[1] != -1) + close (err_pdes[1]); /* :end chunk */ state = XMALLOC (struct pipe_state); state->pid = pid; @@ -144,15 +151,18 @@ pipe_close (struct serial *scb) int pid = state->pid; close (scb->fd); scb->fd = -1; + if (scb->error_fd != -1) + close (scb->error_fd); + scb->error_fd = -1; xfree (state); scb->state = NULL; kill (pid, SIGTERM); - /* Might be useful to check that the child does die. */ + /* Might be useful to check that the child does die, + and while we're waiting for it to die print any remaining + stderr output. */ } } -static struct serial_ops pipe_ops; - void _initialize_ser_pipe (void) {