/* subprocs.c --- choosing, spawning, and killing screenhacks.
- * xscreensaver, Copyright (c) 1991-2008 Jamie Zawinski <jwz@jwz.org>
+ * xscreensaver, Copyright (c) 1991-2015 Jamie Zawinski <jwz@jwz.org>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
void
unblock_sigchld (void)
{
+ if (block_sigchld_handler <= 0)
+ abort();
+
+ if (block_sigchld_handler <= 1) /* only unblock if count going to 0 */
+ {
#ifdef HAVE_SIGACTION
struct sigaction sa;
sigset_t child_set;
#else /* !HAVE_SIGACTION */
signal(SIGPIPE, SIG_DFL);
#endif /* !HAVE_SIGACTION */
+ }
block_sigchld_handler--;
}
clean_job_list();
- if (block_sigchld_handler)
+ if (in_signal_handler_p)
/* This function should not be called from the signal handler. */
abort();
sigchld_handler (int sig)
{
saver_info *si = global_si_kludge; /* I hate C so much... */
+ in_signal_handler_p++;
if (si->prefs.debug_p)
{
}
init_sigchld();
+ in_signal_handler_p--;
}
#endif /* SIGCHLD */
if (def_path && *def_path)
{
const char *opath = getenv("PATH");
- char *npath = (char *) malloc(strlen(def_path) + strlen(opath) + 20);
+ char *npath;
+ if (! opath) opath = "/bin:/usr/bin"; /* WTF */
+ npath = (char *) malloc(strlen(def_path) + strlen(opath) + 20);
strcpy (npath, "PATH=");
strcat (npath, def_path);
strcat (npath, ":");