* serial.h (gdb_pipe, serial_pipe): Declare.
* serial.c (serial_interface_lookup): Take a const char pointer. (serial_fdopen): Rename to ... (serial_fdopen_ops): ... this. Add an OPS parameter and use it. Call the OPS' fdopen function if there is one. (serial_fdopen): Rewrite as wrapper to serial_fdopen_ops. (serial_pipe): New. (struct serial_ops) <fdopen>: New field. * ser-mingw.c (free_pipe_state): (free_pipe_state): Close output on non-pex pipes. (pipe_windows_fdopen): New. (gdb_pipe): New. (_initialize_ser_windows): Register pipe_windows_fdopen. * ser-go32.c (gdb_pipe): New. * ser-pipe.c (pipe_close): Close file descriptor even if there's no state pointer. (pipe_ops): Delete. (gdb_pipe): New.
This commit is contained in:
parent
3da10d80f8
commit
58f07bae95
6 changed files with 159 additions and 24 deletions
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue