/* subprocs.c --- choosing, spawning, and killing screenhacks.
- * xscreensaver, Copyright (c) 1991-2016 Jamie Zawinski <jwz@jwz.org>
+ * xscreensaver, Copyright (c) 1991-2017 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
#endif /* VMS */
#include <signal.h> /* for the signal names */
+#include <time.h>
#if !defined(SIGCHLD) && defined(SIGCLD)
# define SIGCHLD SIGCLD
const char *in = cmd;
char *out = name;
int got_eq = 0;
- int first = 1;
clean_job_list();
{ /* then get the next token instead. */
got_eq = 0;
out = name;
- first = 0;
goto AGAIN;
}
{
int result = 0;
int wait_status = 0;
+ pid_t pid = -1;
FILE *f = fdopen (in, "r");
unsigned long v = 0;
close (errin);
}
- /* Wait for the child to die. */
- waitpid (-1, &wait_status, 0);
+ /* Wait for the child to die - wait for this pid only, not others. */
+ pid = waitpid (forked, &wait_status, 0);
+ if (si->prefs.debug_p)
+ {
+ write_string (STDERR_FILENO, blurb());
+ write_string (STDERR_FILENO, ": waitpid(");
+ write_long (STDERR_FILENO, (long) forked);
+ write_string (STDERR_FILENO, ") ==> ");
+ write_long (STDERR_FILENO, (long) pid);
+ write_string (STDERR_FILENO, "\n");
+ }
unblock_sigchld(); /* child is dead and waited, unblock now. */