/*
- * "$Id: dirsvc.c,v 1.108 2003/02/05 21:10:16 mike Exp $"
+ * "$Id: dirsvc.c,v 1.109 2003/03/12 18:49:04 mike Exp $"
*
* Directory services routines for the Common UNIX Printing System (CUPS).
*
to; /* Timeout time */
- if (!Browsing || !(BrowseProtocols & BROWSE_CUPS))
+ if (!Browsing || !BrowseProtocols)
return;
/*
struct sockaddr_in addr; /* Broadcast address */
- if (!Browsing)
+ if (!Browsing || !BrowseProtocols)
return;
if (BrowseProtocols & BROWSE_CUPS)
{
LogMessage(L_ERROR, "StartBrowsing: Unable to create broadcast socket - %s.",
strerror(errno));
- Browsing = 0;
+ BrowseProtocols &= ~BROWSE_CUPS;
return;
}
close(BrowseSocket);
#endif /* WIN32 */
- BrowseSocket = -1;
- Browsing = 0;
+ BrowseSocket = -1;
+ BrowseProtocols &= ~BROWSE_CUPS;
return;
}
close(BrowseSocket);
#endif /* WIN32 */
- BrowseSocket = -1;
- Browsing = 0;
+ BrowseSocket = -1;
+ BrowseProtocols &= ~BROWSE_CUPS;
return;
}
char interval[10]; /* Poll interval */
int statusfds[2]; /* Status pipe */
int fd; /* Current file descriptor */
+#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
+ struct sigaction action; /* POSIX signal handler */
+#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
/*
{
sprintf(sport, "%d", poll->port);
+ /*
+ * Block signals before forking...
+ */
+
+ HoldSignals();
+
if ((pid = fork()) == 0)
{
/*
for (fd = 3; fd < MaxFDs; fd ++)
close(fd);
+ /*
+ * Unblock signals before doing the exec...
+ */
+
+#ifdef HAVE_SIGSET
+ sigset(SIGTERM, SIG_DFL);
+ sigset(SIGCHLD, SIG_DFL);
+#elif defined(HAVE_SIGACTION)
+ memset(&action, 0, sizeof(action));
+
+ sigemptyset(&action.sa_mask);
+ action.sa_handler = SIG_DFL;
+
+ sigaction(SIGTERM, &action, NULL);
+ sigaction(SIGCHLD, &action, NULL);
+#else
+ signal(SIGTERM, SIG_DFL);
+ signal(SIGCHLD, SIG_DFL);
+#endif /* HAVE_SIGSET */
+
+ ReleaseSignals();
+
/*
* Execute the polling daemon...
*/
LogMessage(L_DEBUG, "StartPolling: Started polling daemon for %s:%d, pid = %d",
poll->hostname, poll->port, pid);
}
+
+ ReleaseSignals();
}
close(statusfds[1]);
void
StopBrowsing(void)
{
- if (!Browsing)
+ if (!Browsing || !BrowseProtocols)
return;
if (BrowseProtocols & BROWSE_CUPS)
/*
- * End of "$Id: dirsvc.c,v 1.108 2003/02/05 21:10:16 mike Exp $".
+ * End of "$Id: dirsvc.c,v 1.109 2003/03/12 18:49:04 mike Exp $".
*/