* RFC: Wait for exit after "target remote |"
@ 2010-08-30 19:12 Daniel Jacobowitz
2010-09-01 2:07 ` Joel Brobecker
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Jacobowitz @ 2010-08-30 19:12 UTC (permalink / raw)
To: gdb-patches
While looking at cpexprs.exp I found that halfway through the test my
system had hundreds of zombie simulator processes. Turns out,
ser-pipe forks and execs but never ever waits! This bug has been
lurking for years.
Does anyone think this patch is a bad idea? It's straightforward
enough; we've already sent SIGTERM, so then call waitpid. If the
child is wedged and does not respond to SIGTERM, then GDB may hang;
it's not trivial to retry and send SIGKILL. But, IMO, that's not a
likely scenario.
Comments welcome!
--
Daniel Jacobowitz
CodeSourcery
2010-08-30 Daniel Jacobowitz <dan@codesourcery.com>
* config.in, configure: Regenerated.
* configure.ac: Check for waitpid.
* ser-pipe.c (pipe_close): Wait for the program to exit.
Index: config.in
===================================================================
RCS file: /cvs/src/src/gdb/config.in,v
retrieving revision 1.122
diff -u -p -r1.122 config.in
--- config.in 28 Jul 2010 23:24:57 -0000 1.122
+++ config.in 30 Aug 2010 19:08:28 -0000
@@ -676,6 +676,9 @@
/* Define to 1 if you have the <vfork.h> header file. */
#undef HAVE_VFORK_H
+/* Define to 1 if you have the `waitpid' function. */
+#undef HAVE_WAITPID
+
/* Define to 1 if you have the <wait.h> header file. */
#undef HAVE_WAIT_H
Index: configure
===================================================================
RCS file: /cvs/src/src/gdb/configure,v
retrieving revision 1.315
diff -u -p -r1.315 configure
--- configure 18 Aug 2010 22:57:46 -0000 1.315
+++ configure 30 Aug 2010 19:08:29 -0000
@@ -12550,7 +12550,7 @@ for ac_func in canonicalize_file_name re
getgid pipe poll pread64 resize_term sbrk setpgid setpgrp setsid \
sigaction sigprocmask sigsetmask socketpair syscall \
ttrace wborder wresize setlocale iconvlist libiconvlist btowc \
- setrlimit getrlimit posix_madvise
+ setrlimit getrlimit posix_madvise waitpid
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
Index: configure.ac
===================================================================
RCS file: /cvs/src/src/gdb/configure.ac,v
retrieving revision 1.129
diff -u -p -r1.129 configure.ac
--- configure.ac 18 Aug 2010 22:57:46 -0000 1.129
+++ configure.ac 30 Aug 2010 19:08:29 -0000
@@ -962,7 +962,7 @@ AC_CHECK_FUNCS([canonicalize_file_name r
getgid pipe poll pread64 resize_term sbrk setpgid setpgrp setsid \
sigaction sigprocmask sigsetmask socketpair syscall \
ttrace wborder wresize setlocale iconvlist libiconvlist btowc \
- setrlimit getrlimit posix_madvise])
+ setrlimit getrlimit posix_madvise waitpid])
AM_LANGINFO_CODESET
# Check the return and argument types of ptrace. No canned test for
Index: ser-pipe.c
===================================================================
RCS file: /cvs/src/src/gdb/ser-pipe.c,v
retrieving revision 1.28
diff -u -p -r1.28 ser-pipe.c
--- ser-pipe.c 20 Aug 2010 18:49:20 -0000 1.28
+++ ser-pipe.c 30 Aug 2010 19:08:29 -0000
@@ -31,6 +31,7 @@
#include <sys/time.h>
#include <fcntl.h>
#include "gdb_string.h"
+#include "gdb_wait.h"
#include <signal.h>
@@ -162,11 +163,14 @@ pipe_close (struct serial *scb)
if (state != NULL)
{
+ int status;
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. */
-
+#ifdef HAVE_WAITPID
+ /* Assume the program will exit after SIGTERM. Might be
+ useful to print any remaining stderr output from
+ scb->error_fd while waiting. */
+ waitpid (state->pid, &status, 0);
+#endif
if (scb->error_fd != -1)
close (scb->error_fd);
scb->error_fd = -1;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: RFC: Wait for exit after "target remote |"
2010-08-30 19:12 RFC: Wait for exit after "target remote |" Daniel Jacobowitz
@ 2010-09-01 2:07 ` Joel Brobecker
2010-09-02 18:41 ` Daniel Jacobowitz
0 siblings, 1 reply; 3+ messages in thread
From: Joel Brobecker @ 2010-09-01 2:07 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches
> 2010-08-30 Daniel Jacobowitz <dan@codesourcery.com>
>
> * config.in, configure: Regenerated.
> * configure.ac: Check for waitpid.
> * ser-pipe.c (pipe_close): Wait for the program to exit.
FWIW, I think that this is an improvement over the previous situation.
Leaving processes behind can be disastrous, whereas I also think that
the chances of a process not dying after a SIGTERM are slim (likely
unintentional).
--
Joel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: RFC: Wait for exit after "target remote |"
2010-09-01 2:07 ` Joel Brobecker
@ 2010-09-02 18:41 ` Daniel Jacobowitz
0 siblings, 0 replies; 3+ messages in thread
From: Daniel Jacobowitz @ 2010-09-02 18:41 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches
On Tue, Aug 31, 2010 at 07:07:22PM -0700, Joel Brobecker wrote:
> > 2010-08-30 Daniel Jacobowitz <dan@codesourcery.com>
> >
> > * config.in, configure: Regenerated.
> > * configure.ac: Check for waitpid.
> > * ser-pipe.c (pipe_close): Wait for the program to exit.
>
> FWIW, I think that this is an improvement over the previous situation.
> Leaving processes behind can be disastrous, whereas I also think that
> the chances of a process not dying after a SIGTERM are slim (likely
> unintentional).
Thanks. In that case, I've put this in (HEAD only).
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-09-02 17:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-30 19:12 RFC: Wait for exit after "target remote |" Daniel Jacobowitz
2010-09-01 2:07 ` Joel Brobecker
2010-09-02 18:41 ` Daniel Jacobowitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).