/*
- * "$Id: main.c 5108 2006-02-15 19:33:09Z mike $"
+ * "$Id: main.c 5305 2006-03-18 03:05:12Z mike $"
*
* Scheduler main loop for the Common UNIX Printing System (CUPS).
*
* main() - Main entry for the CUPS scheduler.
* cupsdClosePipe() - Close a pipe as necessary.
* cupsdOpenPipe() - Create a pipe which is closed on exec.
- * cupsdCatchChildSignals() - Catch SIGCHLD signals...
* cupsdHoldSignals() - Hold child and termination signals.
- * cupsdIgnoreChildSignals() - Ignore SIGCHLD signals...
* cupsdReleaseSignals() - Release signals for delivery.
* cupsdSetString() - Set a string value.
* cupsdSetStringf() - Set a formatted string value.
*/
#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */
- if (RunAsUser)
- sigset(SIGHUP, sigterm_handler);
- else
- sigset(SIGHUP, sighup_handler);
-
+ sigset(SIGCHLD, sigchld_handler);
+ sigset(SIGHUP, sighup_handler);
sigset(SIGPIPE, SIG_IGN);
sigset(SIGTERM, sigterm_handler);
#elif defined(HAVE_SIGACTION)
memset(&action, 0, sizeof(action));
sigemptyset(&action.sa_mask);
- sigaddset(&action.sa_mask, SIGHUP);
-
- if (RunAsUser)
- action.sa_handler = sigterm_handler;
- else
- action.sa_handler = sighup_handler;
+ sigaddset(&action.sa_mask, SIGTERM);
+ sigaddset(&action.sa_mask, SIGCHLD);
+ action.sa_handler = sigchld_handler;
+ sigaction(SIGCHLD, &action, NULL);
+ sigemptyset(&action.sa_mask);
+ sigaddset(&action.sa_mask, SIGHUP);
+ action.sa_handler = sighup_handler;
sigaction(SIGHUP, &action, NULL);
sigemptyset(&action.sa_mask);
action.sa_handler = sigterm_handler;
sigaction(SIGTERM, &action, NULL);
#else
- if (RunAsUser)
- signal(SIGHUP, sigterm_handler);
- else
- signal(SIGHUP, sighup_handler);
-
+ signal(SIGCLD, sigchld_handler); /* No, SIGCLD isn't a typo... */
+ signal(SIGHUP, sighup_handler);
signal(SIGPIPE, SIG_IGN);
signal(SIGTERM, sigterm_handler);
#endif /* HAVE_SIGSET */
kill(i, SIGUSR1);
}
+#ifdef __APPLE__
/*
* Start power management framework...
*/
cupsdStartSystemMonitor();
-
- /*
- * If the administrator has configured the server to run as an unpriviledged
- * user, change to that user now...
- */
-
- if (RunAsUser)
- {
- setgid(Group);
- setgroups(1, &Group);
- setuid(User);
- }
-
- /*
- * Catch signals...
- */
-
- cupsdCatchChildSignals();
+#endif /* __APPLE__ */
/*
* Start any pending print jobs...
cupsdUpdatePolling();
#ifdef HAVE_LIBSLP
- if (((BrowseLocalProtocols | BrowseRemoteProtocols) & BROWSE_SLP) &&
+ if ((BrowseRemoteProtocols & BROWSE_SLP) &&
BrowseSLPRefresh <= current_time)
cupsdUpdateSLPBrowse();
#endif /* HAVE_LIBSLP */
+
+#ifdef HAVE_LDAP
+ if ((BrowseRemoteProtocols & BROWSE_LDAP) &&
+ BrowseLDAPRefresh <= current_time)
+ cupsdUpdateLDAPBrowse();
+#endif /* HAVE_LDAP */
}
if (Browsing && BrowseLocalProtocols && current_time > browse_time)
mem.fsmblks + mem.fordblks);
#endif /* HAVE_MALLINFO */
- string_count = _cups_sp_statistics(&alloc_bytes, &total_bytes);
+ string_count = _cupsStrStatistics(&alloc_bytes, &total_bytes);
cupsdLogMessage(CUPSD_LOG_DEBUG2,
"stringpool: " CUPS_LLFMT " strings, "
CUPS_LLFMT " allocated, " CUPS_LLFMT " total bytes",
cupsdFreeAllJobs();
+#ifdef __APPLE__
cupsdStopSystemMonitor();
+#endif /* __APPLE__ */
#ifdef HAVE_LAUNCHD
/*
*/
if (pipe(fds))
+ {
+ fds[0] = -1;
+ fds[1] = -1;
+
return (-1);
+ }
/*
* Set the "close on exec" flag on each end of the pipe...
{
close(fds[0]);
close(fds[1]);
+
+ fds[0] = -1;
+ fds[1] = -1;
+
return (-1);
}
{
close(fds[0]);
close(fds[1]);
+
+ fds[0] = -1;
+ fds[1] = -1;
+
return (-1);
}
}
-/*
- * 'cupsdCatchChildSignals()' - Catch SIGCHLD signals...
- */
-
-void
-cupsdCatchChildSignals(void)
-{
-#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
- struct sigaction action; /* Actions for POSIX signals */
-#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
-
-
-#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */
- sigset(SIGCHLD, sigchld_handler);
-#elif defined(HAVE_SIGACTION)
- memset(&action, 0, sizeof(action));
-
- sigemptyset(&action.sa_mask);
- sigaddset(&action.sa_mask, SIGTERM);
- sigaddset(&action.sa_mask, SIGCHLD);
- action.sa_handler = sigchld_handler;
- sigaction(SIGCHLD, &action, NULL);
-#else
- signal(SIGCLD, sigchld_handler); /* No, SIGCLD isn't a typo... */
-#endif /* HAVE_SIGSET */
-}
-
-
/*
* 'cupsdClearString()' - Clear a string.
*/
}
-/*
- * 'cupsdIgnoreChildSignals()' - Ignore SIGCHLD signals...
- *
- * We don't really ignore them, we set the signal handler to SIG_DFL,
- * since some OS's rely on signals for the wait4() function to work.
- */
-
-void
-cupsdIgnoreChildSignals(void)
-{
-#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
- struct sigaction action; /* Actions for POSIX signals */
-#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
-
-
-#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */
- sigset(SIGCHLD, SIG_DFL);
-#elif defined(HAVE_SIGACTION)
- memset(&action, 0, sizeof(action));
-
- sigemptyset(&action.sa_mask);
- sigaddset(&action.sa_mask, SIGCHLD);
- action.sa_handler = SIG_DFL;
- sigaction(SIGCHLD, &action, NULL);
-#else
- signal(SIGCLD, SIG_DFL); /* No, SIGCLD isn't a typo... */
-#endif /* HAVE_SIGSET */
-}
-
-
/*
* 'cupsdReleaseSignals()' - Release signals for delivery.
*/
}
#endif /* HAVE_LIBSLP */
+#ifdef HAVE_LDAP
+ if ((BrowseLocalProtocols & BROWSE_LDAP) && (BrowseLDAPRefresh < timeout))
+ {
+ timeout = BrowseLDAPRefresh;
+ why = "update LDAP browsing";
+ }
+#endif /* HAVE_LDAP */
+
if (BrowseLocalProtocols & BROWSE_CUPS)
{
for (p = (cupsd_printer_t *)cupsArrayFirst(Printers);
/*
- * End of "$Id: main.c 5108 2006-02-15 19:33:09Z mike $".
+ * End of "$Id: main.c 5305 2006-03-18 03:05:12Z mike $".
*/