mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-10-18 21:34:13 +08:00
* ser-base.c (generic_readchar): Watch for EOF in read of error_fd.
* ser-pipe.c (pipe_open): Fix file descriptor leaks. (pipe_close): Ditto.
This commit is contained in:
@ -1,3 +1,9 @@
|
|||||||
|
2010-04-19 Doug Evans <dje@google.com>
|
||||||
|
|
||||||
|
* ser-base.c (generic_readchar): Watch for EOF in read of error_fd.
|
||||||
|
* ser-pipe.c (pipe_open): Fix file descriptor leaks.
|
||||||
|
(pipe_close): Ditto.
|
||||||
|
|
||||||
2010-04-19 Pierre Muller <muller@ics.u-strasbg.fr>
|
2010-04-19 Pierre Muller <muller@ics.u-strasbg.fr>
|
||||||
|
|
||||||
* configure.tgt (x86_64-*-mingw*): Set BUILD_GDBSERVER to yes.
|
* configure.tgt (x86_64-*-mingw*): Set BUILD_GDBSERVER to yes.
|
||||||
|
@ -361,7 +361,7 @@ generic_readchar (struct serial *scb, int timeout,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
s = read (scb->error_fd, &buf, to_read);
|
s = read (scb->error_fd, &buf, to_read);
|
||||||
if (s == -1)
|
if (s <= 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* In theory, embedded newlines are not a problem.
|
/* In theory, embedded newlines are not a problem.
|
||||||
|
@ -66,7 +66,11 @@ pipe_open (struct serial *scb, const char *name)
|
|||||||
if (socketpair (AF_UNIX, SOCK_STREAM, 0, pdes) < 0)
|
if (socketpair (AF_UNIX, SOCK_STREAM, 0, pdes) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
if (socketpair (AF_UNIX, SOCK_STREAM, 0, err_pdes) < 0)
|
if (socketpair (AF_UNIX, SOCK_STREAM, 0, err_pdes) < 0)
|
||||||
|
{
|
||||||
|
close (pdes[0]);
|
||||||
|
close (pdes[1]);
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Create the child process to run the command in. Note that the
|
/* Create the child process to run the command in. Note that the
|
||||||
apparent call to vfork() below *might* actually be a call to
|
apparent call to vfork() below *might* actually be a call to
|
||||||
@ -123,6 +127,8 @@ pipe_open (struct serial *scb, const char *name)
|
|||||||
|
|
||||||
/* Parent. */
|
/* Parent. */
|
||||||
close (pdes[1]);
|
close (pdes[1]);
|
||||||
|
if (err_pdes[1] != -1)
|
||||||
|
close (err_pdes[1]);
|
||||||
/* :end chunk */
|
/* :end chunk */
|
||||||
state = XMALLOC (struct pipe_state);
|
state = XMALLOC (struct pipe_state);
|
||||||
state->pid = pid;
|
state->pid = pid;
|
||||||
@ -145,10 +151,15 @@ pipe_close (struct serial *scb)
|
|||||||
int pid = state->pid;
|
int pid = state->pid;
|
||||||
close (scb->fd);
|
close (scb->fd);
|
||||||
scb->fd = -1;
|
scb->fd = -1;
|
||||||
|
if (scb->error_fd != -1)
|
||||||
|
close (scb->error_fd);
|
||||||
|
scb->error_fd = -1;
|
||||||
xfree (state);
|
xfree (state);
|
||||||
scb->state = NULL;
|
scb->state = NULL;
|
||||||
kill (pid, SIGTERM);
|
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. */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user