aboutsummaryrefslogtreecommitdiff
path: root/gdb/fork-child.c
diff options
context:
space:
mode:
authorJim Kingdon <jkingdon@engr.sgi.com>1993-09-30 20:41:17 +0000
committerJim Kingdon <jkingdon@engr.sgi.com>1993-09-30 20:41:17 +0000
commit01dfd415135645a6703f8d3bb2d591bdf89b51ef (patch)
tree1fdc0c488ed1ec90885ba6abc8e66b89d147e42b /gdb/fork-child.c
parent8d658c0866a3cb9beb3a049e1110858c29458e7d (diff)
downloadgdb-01dfd415135645a6703f8d3bb2d591bdf89b51ef.zip
gdb-01dfd415135645a6703f8d3bb2d591bdf89b51ef.tar.gz
gdb-01dfd415135645a6703f8d3bb2d591bdf89b51ef.tar.bz2
* fork-child.c (fork_inferior): Don't call target_terminal_init
and target_terminal_inferior until we are sure that the inferior has called gdb_setpgid. This fixes PR 2900 (Schauer tracked it down and was able to reliably reproduce it by putting a sleep() before the gdb_setpgid()).
Diffstat (limited to 'gdb/fork-child.c')
-rw-r--r--gdb/fork-child.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/gdb/fork-child.c b/gdb/fork-child.c
index 8eade52..905dd0c 100644
--- a/gdb/fork-child.c
+++ b/gdb/fork-child.c
@@ -61,6 +61,7 @@ fork_inferior (exec_file, allargs, env, traceme_fun, init_trace_fun)
static char default_shell_file[] = SHELL_FILE;
int len;
int pending_execs;
+ int terminal_initted;
/* Set debug_fork then attach to the child while it sleeps, to debug. */
static int debug_fork = 0;
/* This is set to the result of setpgrp, which if vforked, will be visible
@@ -268,12 +269,7 @@ fork_inferior (exec_file, allargs, env, traceme_fun, init_trace_fun)
init_wait_for_inferior ();
- /* Set up the "saved terminal modes" of the inferior
- based on what modes we are starting it with. */
- target_terminal_init ();
-
- /* Install inferior's terminal modes. */
- target_terminal_inferior ();
+ terminal_initted = 0;
while (1)
{
@@ -288,6 +284,21 @@ fork_inferior (exec_file, allargs, env, traceme_fun, init_trace_fun)
else
{
/* We handle SIGTRAP, however; it means child did an exec. */
+ if (!terminal_initted)
+ {
+ /* Now that the child has exec'd we know it has already set its
+ process group. On POSIX systems, tcsetpgrp will fail with
+ EPERM if we try it before the child's setpgid. */
+
+ /* Set up the "saved terminal modes" of the inferior
+ based on what modes we are starting it with. */
+ target_terminal_init ();
+
+ /* Install inferior's terminal modes. */
+ target_terminal_inferior ();
+
+ terminal_initted = 1;
+ }
if (0 == --pending_execs)
break;
resume (0, 0); /* Just make it go on */