struct remote_thread_call *tmp = priv->waitDispatch;
struct remote_thread_call *prev;
char ignore;
+#ifdef HAVE_PTHREAD_H
sigset_t oldmask, blockedsigs;
+#endif
fds[0].events = fds[0].revents = 0;
fds[1].events = fds[1].revents = 0;
* after the call (RHBZ#567931). Same for SIGCHLD and SIGPIPE
* at the suggestion of Paolo Bonzini and Daniel Berrange.
*/
+#ifdef HAVE_PTHREAD_H
sigemptyset (&blockedsigs);
sigaddset (&blockedsigs, SIGWINCH);
sigaddset (&blockedsigs, SIGCHLD);
sigaddset (&blockedsigs, SIGPIPE);
ignore_value (pthread_sigmask(SIG_BLOCK, &blockedsigs, &oldmask));
+#endif
repoll:
ret = poll(fds, ARRAY_CARDINALITY(fds), -1);
if (ret < 0 && errno == EAGAIN)
goto repoll;
+#ifdef HAVE_PTHREAD_H
ignore_value (pthread_sigmask(SIG_SETMASK, &oldmask, NULL));
+#endif
remoteDriverLock(priv);
*/
int virFork(pid_t *pid) {
+# ifdef HAVE_PTHREAD_H
sigset_t oldmask, newmask;
+# endif
struct sigaction sig_action;
int saved_errno, ret = -1;
* Need to block signals now, so that child process can safely
* kill off caller's signal handlers without a race.
*/
+# ifdef HAVE_PTHREAD_H
sigfillset(&newmask);
if (pthread_sigmask(SIG_SETMASK, &newmask, &oldmask) != 0) {
saved_errno = errno;
"%s", _("cannot block signals"));
goto cleanup;
}
+# endif
/* Ensure we hold the logging lock, to protect child processes
* from deadlocking on another thread's inherited mutex state */
virLogUnlock();
if (*pid < 0) {
+# ifdef HAVE_PTHREAD_H
/* attempt to restore signal mask, but ignore failure, to
avoid obscuring the fork failure */
ignore_value (pthread_sigmask(SIG_SETMASK, &oldmask, NULL));
+# endif
virReportSystemError(saved_errno,
"%s", _("cannot fork child process"));
goto cleanup;
/* parent process */
+# ifdef HAVE_PTHREAD_H
/* Restore our original signal mask now that the child is
safely running */
if (pthread_sigmask(SIG_SETMASK, &oldmask, NULL) != 0) {
virReportSystemError(errno, "%s", _("cannot unblock signals"));
goto cleanup;
}
+# endif
ret = 0;
} else {
sigaction(i, &sig_action, NULL);
}
+# ifdef HAVE_PTHREAD_H
/* Unmask all signals in child, since we've no idea
what the caller's done with their signal mask
and don't want to propagate that to children */
virReportSystemError(errno, "%s", _("cannot unblock signals"));
goto cleanup;
}
+# endif
ret = 0;
}