* breakpoint.c, breakpoint.h (breakpoint_init_inferior): New function
[deliverable/binutils-gdb.git] / gdb / fork-child.c
index 40f76802c9a215584bb5fb02d3e0fb1f178c1d89..905dd0c8b542b5ed97b349f0a2fe42f5619ad0c4 100644 (file)
@@ -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
@@ -242,6 +243,8 @@ fork_inferior (exec_file, allargs, env, traceme_fun, init_trace_fun)
      initialize anything target-vector-specific that needs initializing.  */
   (*init_trace_fun)(pid);
 
+  init_thread_list();
+
 #ifdef CREATE_INFERIOR_HOOK
   CREATE_INFERIOR_HOOK (pid);
 #endif  
@@ -266,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)
     {
@@ -286,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 */
This page took 0.023346 seconds and 4 git commands to generate.