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);
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)
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);
int i = 0;
unsigned char signal;
unsigned int mem_addr, len;
- char argvec[1024];
if (setjmp(toplevel))
{
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 */