From 602e3198bc03297b7d9cb34ed3838272254eba1f Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Wed, 28 Aug 2013 17:40:58 +0000 Subject: [PATCH] PR server/15604 gdb/gdbserver/ 2013-08-28 Jan Kratochvil PR server/15604 * linux-low.c: Include filestuff.h. (linux_create_inferior) : Call close_most_fds. * lynx-low.c: Include filestuff.h. (lynx_create_inferior) : Call close_most_fds. * server.c: Include filestuff.h. (main): Call notice_open_fds. * spu-low.c: Include filestuff.h. (spu_create_inferior) : Call close_most_fds. --- gdb/gdbserver/ChangeLog | 12 ++++++++++++ gdb/gdbserver/linux-low.c | 2 ++ gdb/gdbserver/lynx-low.c | 3 +++ gdb/gdbserver/server.c | 5 +++++ gdb/gdbserver/spu-low.c | 2 ++ 5 files changed, 24 insertions(+) diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index fe3660c..913fe42 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,15 @@ +2013-08-28 Jan Kratochvil + + PR server/15604 + * linux-low.c: Include filestuff.h. + (linux_create_inferior) : Call close_most_fds. + * lynx-low.c: Include filestuff.h. + (lynx_create_inferior) : Call close_most_fds. + * server.c: Include filestuff.h. + (main): Call notice_open_fds. + * spu-low.c: Include filestuff.h. + (spu_create_inferior) : Call close_most_fds. + 2013-08-22 Luis Machado * Makefile.in: Explain why ../target and ../nat are not diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index 12208dc..7db1fc8 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -44,6 +44,7 @@ #include "gdb_stat.h" #include #include +#include "filestuff.h" #ifndef ELFMAG0 /* Don't include here. If it got included by gdb_proc_service.h then ELFMAG0 will have been defined. If it didn't get included by @@ -580,6 +581,7 @@ linux_create_inferior (char *program, char **allargs) if (pid == 0) { + close_most_fds (); ptrace (PTRACE_TRACEME, 0, (PTRACE_TYPE_ARG3) 0, (PTRACE_TYPE_ARG4) 0); #ifndef __ANDROID__ /* Bionic doesn't use SIGRTMIN the way glibc does. */ diff --git a/gdb/gdbserver/lynx-low.c b/gdb/gdbserver/lynx-low.c index 4cf8683..3c75b62 100644 --- a/gdb/gdbserver/lynx-low.c +++ b/gdb/gdbserver/lynx-low.c @@ -27,6 +27,7 @@ #include #include "gdb_wait.h" #include +#include "filestuff.h" int using_threads = 1; @@ -240,6 +241,8 @@ lynx_create_inferior (char *program, char **allargs) { int pgrp; + close_most_fds (); + /* Switch child to its own process group so that signals won't directly affect gdbserver. */ pgrp = getpid(); diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c index a4b9129..ebdaba5 100644 --- a/gdb/gdbserver/server.c +++ b/gdb/gdbserver/server.c @@ -28,6 +28,7 @@ #endif #include "gdb_wait.h" #include "btrace-common.h" +#include "filestuff.h" /* The thread set with an `Hc' packet. `Hc' is deprecated in favor of `vCont'. Note the multi-process extensions made `vCont' a @@ -2850,6 +2851,10 @@ main (int argc, char *argv[]) exit (1); } + /* Remember stdio descriptors. LISTEN_DESC must not be listed, it will be + opened by remote_prepare. */ + notice_open_fds (); + /* We need to know whether the remote connection is stdio before starting the inferior. Inferiors created in this scenario have stdin,stdout redirected. So do this here before we call diff --git a/gdb/gdbserver/spu-low.c b/gdb/gdbserver/spu-low.c index 6e3974a..e604b9f 100644 --- a/gdb/gdbserver/spu-low.c +++ b/gdb/gdbserver/spu-low.c @@ -29,6 +29,7 @@ #include #include #include +#include "filestuff.h" /* Some older glibc versions do not define this. */ #ifndef __WNOTHREAD @@ -274,6 +275,7 @@ spu_create_inferior (char *program, char **allargs) if (pid == 0) { + close_most_fds (); ptrace (PTRACE_TRACEME, 0, 0, 0); setpgid (0, 0); -- 2.7.4