aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/gdbserver/remote-inflow-sparc.c26
-rw-r--r--gdb/gdbserver/remote-inflow.c22
-rw-r--r--gdb/gdbserver/remote-server.c15
3 files changed, 13 insertions, 50 deletions
diff --git a/gdb/gdbserver/remote-inflow-sparc.c b/gdb/gdbserver/remote-inflow-sparc.c
index e71f56c..382c54f 100644
--- a/gdb/gdbserver/remote-inflow-sparc.c
+++ b/gdb/gdbserver/remote-inflow-sparc.c
@@ -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);
diff --git a/gdb/gdbserver/remote-inflow.c b/gdb/gdbserver/remote-inflow.c
index f093d83..7e91b3d 100644
--- a/gdb/gdbserver/remote-inflow.c
+++ b/gdb/gdbserver/remote-inflow.c
@@ -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);
diff --git a/gdb/gdbserver/remote-server.c b/gdb/gdbserver/remote-server.c
index 6a53390..3d962bc 100644
--- a/gdb/gdbserver/remote-server.c
+++ b/gdb/gdbserver/remote-server.c
@@ -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 */