-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;