summaryrefslogtreecommitdiff
path: root/gdb/ser-pipe.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/ser-pipe.c')
-rw-r--r--gdb/ser-pipe.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/gdb/ser-pipe.c b/gdb/ser-pipe.c
index 07fe65b14e9..d26dc4fa497 100644
--- a/gdb/ser-pipe.c
+++ b/gdb/ser-pipe.c
@@ -157,23 +157,42 @@ pipe_close (struct serial *scb)
{
struct pipe_state *state = scb->state;
+ close (scb->fd);
+ scb->fd = -1;
+
if (state != NULL)
{
- int pid = state->pid;
- close (scb->fd);
- scb->fd = -1;
+ kill (state->pid, SIGTERM);
+ /* Might be useful to check that the child does die,
+ and while we're waiting for it to die print any remaining
+ stderr output. */
+
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,
- and while we're waiting for it to die print any remaining
- stderr output. */
}
}
+int
+gdb_pipe (int pdes[2])
+{
+#if !HAVE_SOCKETPAIR
+ errno = ENOSYS;
+ return -1;
+#else
+
+ if (socketpair (AF_UNIX, SOCK_STREAM, 0, pdes) < 0)
+ return -1;
+
+ /* If we don't do this, GDB simply exits when the remote side
+ dies. */
+ signal (SIGPIPE, SIG_IGN);
+ return 0;
+#endif
+}
+
void
_initialize_ser_pipe (void)
{