extern saver_info *global_si_kludge; /* I hate C so much... */
-static void hack_environment (saver_screen_info *ssi);
+static void hack_subproc_environment (saver_screen_info *ssi);
static void
static struct screenhack_job *jobs = 0;
-#ifdef DEBUG
-static void
+/* for debugging -- nothing calls this, but it's useful to invoke from gdb. */
+void
show_job_list (void)
{
struct screenhack_job *job;
job->name);
fprintf (stderr, "\n");
}
-#endif
static void clean_job_list (void);
{
saver_info *si = global_si_kludge; /* I hate C so much... */
-#ifdef DEBUG
if (si->prefs.debug_p)
fprintf(stderr, "%s: got SIGCHLD%s\n", progname,
(block_sigchld_handler ? " (blocked)" : ""));
-#endif /* DEBUG */
if (block_sigchld_handler < 0)
abort();
errno = 0;
kid = waitpid (-1, &wait_status, WNOHANG|WUNTRACED);
-#ifdef DEBUG
+
if (si->prefs.debug_p)
- if (kid < 0 && errno)
- fprintf (stderr, "%s: waitpid(-1) ==> %ld (%d)\n", progname,
- (long) kid, errno);
- else
- fprintf (stderr, "%s: waitpid(-1) ==> %ld\n", progname, (long) kid);
-#endif /* DEBUG */
+ {
+ if (kid < 0 && errno)
+ fprintf (stderr, "%s: waitpid(-1) ==> %ld (%d)\n", progname,
+ (long) kid, errno);
+ else
+ fprintf (stderr, "%s: waitpid(-1) ==> %ld\n", progname,
+ (long) kid);
+ }
/* 0 means no more children to reap.
-1 means error -- except "interrupted system call" isn't a "real"
case 0:
close (ConnectionNumber (si->dpy)); /* close display fd */
nice_subproc (p->nice_inferior); /* change process priority */
- hack_environment (ssi); /* set $DISPLAY */
+ hack_subproc_environment (ssi); /* set $DISPLAY */
exec_screenhack (si, hack); /* this does not return */
abort();
break;
spawn_screenhack (saver_info *si, Bool first_time_p)
{
int i;
+
+ if (!monitor_powered_on_p (si))
+ {
+ if (si->prefs.verbose_p)
+ printf ("%s: server reports that monitor has powered down; "
+ "not launching a new hack.\n", progname);
+ return;
+ }
+
for (i = 0; i < si->nscreens; i++)
{
saver_screen_info *ssi = &si->screens[i];
{
int i;
for (i = 0; saved_argv [i]; i++);
- /* add the -demo switch; save_argv() left room for this. */
- saved_argv [i] = "-demo";
+ /* add the -initial-demo-mode switch; save_argv() left room for this. */
+ saved_argv [i] = "-initial-demo-mode";
saved_argv [i+1] = 0;
restart_process (si); /* shouldn't return */
saved_argv [i] = 0;
}
static void
-hack_environment (saver_screen_info *ssi)
+hack_subproc_environment (saver_screen_info *ssi)
{
/* Store $DISPLAY into the environment, so that the $DISPLAY variable that
the spawned processes inherit is correct. First, it must be on the same
#endif /* HAVE_PUTENV */
}
+
+void
+hack_environment (saver_info *si)
+{
+#if defined(HAVE_PUTENV) && defined(DEFAULT_PATH_PREFIX)
+ static const char *def_path = DEFAULT_PATH_PREFIX;
+ if (def_path && *def_path)
+ {
+ const char *opath = getenv("PATH");
+ char *npath = (char *) malloc(strlen(def_path) + strlen(opath) + 20);
+ strcpy (npath, "PATH=");
+ strcat (npath, def_path);
+ strcat (npath, ":");
+ strcat (npath, opath);
+
+ if (putenv (npath))
+ abort ();
+ }
+#endif /* HAVE_PUTENV && DEFAULT_PATH_PREFIX */
+}
+
+
\f
/* Change the uid/gid of the screensaver process, so that it is safe for it
to run setuid root (which it needs to do on some systems to read the