- /* Invoke the shell as "/bin/sh -c 'exec prog -arg -arg ...'" */
- av [ac++] = (char *) shell;
- av [ac++] = "-c";
- av [ac++] = command2;
- av [ac] = 0;
-
- execvp (av[0], av); /* shouldn't return. */
-
- {
- char buf [512];
- sprintf (buf, "%s: execvp(\"%s\") failed", blurb(), av[0]);
- perror (buf);
- fflush(stderr);
- fflush(stdout);
- exit (1); /* Note that this only exits a child fork. */
- }
-}
-
-#else /* VMS */
-
-static void
-exec_vms_command (const char *command)
-{
- system (command);
- fflush (stderr);
- fflush (stdout);
- exit (1); /* Note that this only exits a child fork. */
-}
-
-#endif /* !VMS */
-
-
-static void
-exec_screenhack (saver_info *si, const char *command)
-{
- /* I don't believe what a sorry excuse for an operating system UNIX is!
-
- - I want to spawn a process.
- - I want to know it's pid so that I can kill it.
- - I would like to receive a message when it dies of natural causes.
- - I want the spawned process to have user-specified arguments.
-
- If shell metacharacters are present (wildcards, backquotes, etc), the
- only way to parse those arguments is to run a shell to do the parsing
- for you.
-
- And the only way to know the pid of the process is to fork() and exec()
- it in the spawned side of the fork.
-
- But if you're running a shell to parse your arguments, this gives you
- the pid of the *shell*, not the pid of the *process* that you're
- actually interested in, which is an *inferior* of the shell. This also
- means that the SIGCHLD you get applies to the shell, not its inferior.
- (Why isn't that sufficient? I don't remember any more, but it turns
- out that it isn't.)
-
- So, the only solution, when metacharacters are present, is to force the
- shell to exec() its inferior. What a fucking hack! We prepend "exec "
- to the command string, and hope it doesn't contain unquoted semicolons
- or ampersands (we don't search for them, because we don't want to
- prohibit their use in quoted strings (messages, for example) and parsing
- out the various quote characters is too much of a pain.)
-
- (Actually, Clint Wong <clint@jts.com> points out that process groups
- might be used to take care of this problem; this may be worth considering
- some day, except that, 1: this code works now, so why fix it, and 2: from
- what I've seen in Emacs, dealing with process groups isn't especially
- portable.)
- */
- saver_preferences *p = &si->prefs;
-
-#ifndef VMS
- Bool hairy_p = !!strpbrk (command, "*?$&!<>[];`'\\\"=");
- /* note: = is in the above because of the sh syntax "FOO=bar cmd". */
-
- if (getuid() == (uid_t) 0 || geteuid() == (uid_t) 0)