get rid of unused m4 files
[deliverable/binutils-gdb.git] / gdb / fork-child.c
index 1529516c5efb5fa08f44d92c92b3a215c113939c..26b74cf416541e5045f92a18d1051d7b62ba40ef 100644 (file)
@@ -1,5 +1,5 @@
 /* Fork a Unix child process, and set up to debug it, for GDB.
-   Copyright 1990, 1991, 1992 Free Software Foundation, Inc.
+   Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
    Contributed by Cygnus Support.
 
 This file is part of GDB.
@@ -19,6 +19,7 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 #include "defs.h"
+#include <string.h>
 #include "frame.h"  /* required by inferior.h */
 #include "inferior.h"
 #include "target.h"
@@ -29,35 +30,30 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 #include <signal.h>
 
-#ifdef SET_STACK_LIMIT_HUGE
-#include <sys/time.h>
-#include <sys/resource.h>
-
-extern int original_stack_limit;
-#endif /* SET_STACK_LIMIT_HUGE */
-
 extern char **environ;
 
-/* Start an inferior Unix child process and sets inferior_pid to its pid.
-   EXEC_FILE is the file to run.
-   ALLARGS is a string containing the arguments to the program.
-   ENV is the environment vector to pass.  Errors reported with error().  */
-
 #ifndef SHELL_FILE
 #define SHELL_FILE "/bin/sh"
 #endif
 
+/* Start an inferior Unix child process and sets inferior_pid to its pid.
+   EXEC_FILE is the file to run.
+   ALLARGS is a string containing the arguments to the program.
+   ENV is the environment vector to pass.  SHELL_FILE is the shell file,
+   or NULL if we should pick one.  Errors reported with error().  */
+
 void
-fork_inferior (exec_file, allargs, env, traceme_fun, init_trace_fun)
+fork_inferior (exec_file, allargs, env, traceme_fun, init_trace_fun,
+              shell_file)
      char *exec_file;
      char *allargs;
      char **env;
      void (*traceme_fun) PARAMS ((void));
      void (*init_trace_fun) PARAMS ((int));
+     char *shell_file;
 {
   int pid;
   char *shell_command;
-  char *shell_file;
   static char default_shell_file[] = SHELL_FILE;
   int len;
   /* Set debug_fork then attach to the child while it sleeps, to debug. */
@@ -75,9 +71,11 @@ fork_inferior (exec_file, allargs, env, traceme_fun, init_trace_fun)
   /* The user might want tilde-expansion, and in general probably wants
      the program to behave the same way as if run from
      his/her favorite shell.  So we let the shell run it for us.
-     FIXME, this should probably search the local environment (as
-     modified by the setenv command), not the env gdb inherited.  */
-  shell_file = getenv ("SHELL");
+     FIXME-maybe, we might want a "set shell" command so the user can change
+     the shell from within GDB (if so, change callers which pass in a non-NULL
+     shell_file too).  */
+  if (shell_file == NULL)
+    shell_file = getenv ("SHELL");
   if (shell_file == NULL)
     shell_file = default_shell_file;
 
@@ -195,17 +193,6 @@ fork_inferior (exec_file, allargs, env, traceme_fun, init_trace_fun)
       if (debug_setpgrp == -1)
         perror("setpgrp failed in child");
 
-#ifdef SET_STACK_LIMIT_HUGE
-      /* Reset the stack limit back to what it was.  */
-      {
-       struct rlimit rlim;
-
-       getrlimit (RLIMIT_STACK, &rlim);
-       rlim.rlim_cur = original_stack_limit;
-       setrlimit (RLIMIT_STACK, &rlim);
-      }
-#endif /* SET_STACK_LIMIT_HUGE */
-
       /* Ask the tty subsystem to switch to the one we specified earlier
         (or to share the current terminal, if none was specified).  */
 
@@ -272,11 +259,14 @@ startup_inferior (ntraps)
 
   terminal_initted = 0;
 
+#ifdef STARTUP_INFERIOR
+  STARTUP_INFERIOR (pending_execs);
+#else
   while (1)
     {
       stop_soon_quietly = 1;   /* Make wait_for_inferior be quiet */
       wait_for_inferior ();
-      if (stop_signal != SIGTRAP)
+      if (stop_signal != TARGET_SIGNAL_TRAP)
        {
          /* Let shell child handle its own signals in its own way */
          /* FIXME, what if child has exit()ed?  Must exit loop somehow */
@@ -302,8 +292,9 @@ startup_inferior (ntraps)
            }
          if (0 == --pending_execs)
            break;
-         resume (0, 0);                /* Just make it go on */
+         resume (0, TARGET_SIGNAL_0);          /* Just make it go on */
        }
     }
+#endif /* STARTUP_INFERIOR */
   stop_soon_quietly = 0;
 }
This page took 0.02394 seconds and 4 git commands to generate.