+ /* If we decided above to start up with a shell, we exec the
+ shell, "-c" says to interpret the next arg as a shell command
+ to execute, and this command is "exec <target-program>
+ <args>". "-f" means "fast startup" to the c-shell, which
+ means don't do .cshrc file. Doing .cshrc may cause fork/exec
+ events which will confuse debugger start-up code. */
+ if (shell)
+ {
+ execlp (shell_file, shell_file, "-c", shell_command, (char *) 0);
+
+ /* If we get here, it's an error. */
+ fprintf_unfiltered (gdb_stderr, "Cannot exec %s: %s.\n", shell_file,
+ safe_strerror (errno));
+ gdb_flush (gdb_stderr);
+ _exit (0177);
+ }
+ else
+ {
+ /* Otherwise, we directly exec the target program with
+ execvp. */
+ int i;
+ char *errstring;
+
+ execvp (exec_file, argv);
+
+ /* If we get here, it's an error. */
+ errstring = safe_strerror (errno);
+ fprintf_unfiltered (gdb_stderr, "Cannot exec %s ", exec_file);
+
+ i = 1;
+ while (argv[i] != NULL)
+ {
+ if (i != 1)
+ fprintf_unfiltered (gdb_stderr, " ");
+ fprintf_unfiltered (gdb_stderr, "%s", argv[i]);
+ i++;
+ }
+ fprintf_unfiltered (gdb_stderr, ".\n");
+#if 0
+ /* This extra info seems to be useless. */
+ fprintf_unfiltered (gdb_stderr, "Got error %s.\n", errstring);
+#endif
+ gdb_flush (gdb_stderr);
+ _exit (0177);
+ }