* gdbserver/Makefile.in (gdbserver): Use -lbsd.
authorStu Grossman <grossman@cygnus>
Thu, 3 Jun 1993 10:52:57 +0000 (10:52 +0000)
committerStu Grossman <grossman@cygnus>
Thu, 3 Jun 1993 10:52:57 +0000 (10:52 +0000)
* gdbserver/remote-inflow{-sparc}.c (create_inferior):  Don't use a
shell when running the child, as args have been expanded by the
time we get here.  Simplify calling convention.
* gdbserver/remote-server.c (main):  Use new calling convention
for create_inferior, remove defunct code for coalescing argv.
Remove extra calls to mywait(), as we no longer have to wade
through a shell.

gdb/gdbserver/remote-inflow-sparc.c
gdb/gdbserver/remote-inflow.c
gdb/gdbserver/remote-server.c

index e71f56c..382c54f 100644 (file)
@@ -59,37 +59,23 @@ int query ();
    ENV is the environment vector to pass.  */
 
 int
-create_inferior (allargs, env)
+create_inferior (program, allargs)
+     char *program;
      char **allargs;
-     char **env;
 {
   int pid;
-  extern int sys_nerr;
-  extern char *sys_errlist[];
-  extern int errno;
-  char status;
-  char execbuf[1024];
-
-  /* exec is said to fail if the executable is open.  */
-  /****************close_exec_file ();*****************/
-
-  sprintf (execbuf, "exec %s", allargs);
 
-  pid = vfork ();
+  pid = fork ();
   if (pid < 0)
-    perror_with_name ("vfork");
+    perror_with_name ("fork");
 
   if (pid == 0)
     {
-      /* Run inferior in a separate process group.  */
-      setpgrp (getpid (), getpid ());
-
-      errno = 0;
       ptrace (PTRACE_TRACEME);
 
-      execle ("/bin/sh", "sh", "-c", execbuf, 0, env);
+      execv (program, allargs);
 
-      fprintf (stderr, "Cannot exec /bin/sh: %s.\n",
+      fprintf (stderr, "Cannot exec %s: %s.\n", program,
               errno < sys_nerr ? sys_errlist[errno] : "unknown error");
       fflush (stderr);
       _exit (0177);
index f093d83..7e91b3d 100644 (file)
@@ -68,21 +68,11 @@ int query ();
    ENV is the environment vector to pass.  */
 
 int
-create_inferior (allargs, env)
+create_inferior (program, allargs)
+     char *program;
      char **allargs;
-     char **env;
 {
   int pid;
-  extern int sys_nerr;
-  extern char *sys_errlist[];
-  extern int errno;
-  char status;
-  char execbuf[1024];
-
-  /* exec is said to fail if the executable is open.  */
-  /****************close_exec_file ();*****************/
-
-  sprintf (execbuf, "exec %s", allargs);
 
   pid = fork ();
   if (pid < 0)
@@ -90,15 +80,11 @@ create_inferior (allargs, env)
 
   if (pid == 0)
     {
-      /* Run inferior in a separate process group.  */
-      setpgrp (getpid (), getpid ());
-
-      errno = 0;
       ptrace (PTRACE_TRACEME);
 
-      execle ("/bin/sh", "sh", "-c", execbuf, 0, env);
+      execv (program, allargs);
 
-      fprintf (stderr, "Cannot exec /bin/sh: %s.\n",
+      fprintf (stderr, "Cannot exec %s: %s.\n", program,
               errno < sys_nerr ? sys_errlist[errno] : "unknown error");
       fflush (stderr);
       _exit (0177);
index 6a53390..3d962bc 100644 (file)
@@ -57,7 +57,6 @@ main (argc, argv)
   int i = 0;
   unsigned char signal;
   unsigned int mem_addr, len;
-  char argvec[1024];
 
   if (setjmp(toplevel))
     {
@@ -71,18 +70,10 @@ main (argc, argv)
   initialize ();
   remote_open (argv[1], 0);
 
-  argvec[0] = '\000';
-  for (i = 2; i < argc; i++)
-    strcat(argvec, argv[i]);
+  inferior_pid = create_inferior (argv[2], &argv[2]);
+  fprintf (stderr, "Process %s created; pid = %d\n", argv[2], inferior_pid);
 
-  inferior_pid = create_inferior (argvec, environ);
-  fprintf (stderr, "Process %s created; pid = %d\n", argv[1], inferior_pid);
-
-  signal = mywait (&status);   /* Wait till we are at 1st instr in shell */
-  if (status != 'S' || signal != SIGTRAP)
-    error ("Bad status from shell\n");
-  myresume (0, 0);             /* Start up the shell */
-  signal = mywait (&status);   /* Wait for program to start */
+  signal = mywait (&status);   /* Wait till we are at 1st instr in prog */
 
   /* We are now stopped at the first instruction of the target process */