2 * "$Id: main.c 7681 2008-06-20 21:06:02Z mike $"
4 * Scheduler main loop for the Common UNIX Printing System (CUPS).
6 * Copyright 2007-2008 by Apple Inc.
7 * Copyright 1997-2007 by Easy Software Products, all rights reserved.
9 * These coded instructions, statements, and computer programs are the
10 * property of Apple Inc. and are protected by Federal copyright
11 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
12 * "LICENSE" which should have been included with this file. If this
13 * file is missing or damaged, see the license at "http://www.cups.org/".
17 * main() - Main entry for the CUPS scheduler.
18 * cupsdClosePipe() - Close a pipe as necessary.
19 * cupsdOpenPipe() - Create a pipe which is closed on exec.
20 * cupsdHoldSignals() - Hold child and termination signals.
21 * cupsdReleaseSignals() - Release signals for delivery.
22 * cupsdSetString() - Set a string value.
23 * cupsdSetStringf() - Set a formatted string value.
24 * launchd_checkin() - Check-in with launchd and collect the
26 * launchd_checkout() - Check-out with launchd.
27 * parent_handler() - Catch USR1/CHLD signals...
28 * process_children() - Process all dead children...
29 * sigchld_handler() - Handle 'child' signals from old processes.
30 * sighup_handler() - Handle 'hangup' signals to reconfigure the
32 * sigterm_handler() - Handle 'terminate' signals that stop the
34 * select_timeout() - Calculate the select timeout value.
35 * usage() - Show scheduler usage.
39 * Include necessary headers...
44 #include <sys/resource.h>
52 # define CUPS_KEEPALIVE CUPS_CACHEDIR "/org.cups.cupsd"
53 /* Name of the launchd KeepAlive file */
54 # ifndef LAUNCH_JOBKEY_KEEPALIVE
55 # define LAUNCH_JOBKEY_KEEPALIVE "KeepAlive"
56 # endif /* !LAUNCH_JOBKEY_KEEPALIVE */
57 # ifndef LAUNCH_JOBKEY_PATHSTATE
58 # define LAUNCH_JOBKEY_PATHSTATE "PathState"
59 # endif /* !LAUNCH_JOBKEY_PATHSTATE */
60 # ifndef LAUNCH_JOBKEY_SERVICEIPC
61 # define LAUNCH_JOBKEY_SERVICEIPC "ServiceIPC"
62 # endif /* !LAUNCH_JOBKEY_SERVICEIPC */
63 #endif /* HAVE_LAUNCH_H */
65 #if defined(HAVE_MALLOC_H) && defined(HAVE_MALLINFO)
67 #endif /* HAVE_MALLOC_H && HAVE_MALLINFO */
70 #endif /* HAVE_NOTIFY_H */
72 #if defined(__APPLE__) && defined(HAVE_DLFCN_H)
74 #endif /* __APPLE__ && HAVE_DLFCN_H */
82 static void launchd_checkin(void);
83 static void launchd_checkout(void);
84 #endif /* HAVE_LAUNCHD */
85 static void parent_handler(int sig
);
86 static void process_children(void);
87 static void sigchld_handler(int sig
);
88 static void sighup_handler(int sig
);
89 static void sigterm_handler(int sig
);
90 static long select_timeout(int fds
);
91 static void usage(int status
);
98 static int parent_signal
= 0;
99 /* Set to signal number from child */
100 static int holdcount
= 0; /* Number of times "hold" was called */
101 #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
102 static sigset_t holdmask
; /* Old POSIX signal mask */
103 #endif /* HAVE_SIGACTION && !HAVE_SIGSET */
104 static int dead_children
= 0;
106 static int stop_scheduler
= 0;
107 /* Should the scheduler stop? */
109 #if defined(__APPLE__) && defined(HAVE_DLFCN_H)
110 static const char *PSQLibPath
= "/usr/lib/libPrintServiceQuota.dylib";
111 static const char *PSQLibFuncName
= "PSQUpdateQuota";
112 static void *PSQLibRef
; /* libPrintServiceQuota.dylib */
113 #endif /* HAVE_DLFCN_H */
117 * 'main()' - Main entry for the CUPS scheduler.
120 int /* O - Exit status */
121 main(int argc
, /* I - Number of command-line args */
122 char *argv
[]) /* I - Command-line arguments */
124 int i
; /* Looping var */
125 char *opt
; /* Option character */
126 int fg
; /* Run in the foreground */
127 int fds
; /* Number of ready descriptors */
128 cupsd_client_t
*con
; /* Current client */
129 cupsd_job_t
*job
; /* Current job */
130 cupsd_listener_t
*lis
; /* Current listener */
131 time_t current_time
, /* Current time */
132 activity
, /* Client activity timer */
133 browse_time
, /* Next browse send time */
134 senddoc_time
, /* Send-Document time */
135 expire_time
, /* Subscription expire time */
136 report_time
, /* Malloc/client/job report time */
137 event_time
; /* Last time an event notification was done */
138 long timeout
; /* Timeout for cupsdDoSelect() */
139 struct rlimit limit
; /* Runtime limit */
140 #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
141 struct sigaction action
; /* Actions for POSIX signals */
142 #endif /* HAVE_SIGACTION && !HAVE_SIGSET */
144 cups_file_t
*fp
; /* Fake lpsched lock file */
145 struct stat statbuf
; /* Needed for checking lpsched FIFO */
148 int run_as_child
= 0;
149 /* Needed for Mac OS X fork/exec */
151 time_t netif_time
= 0; /* Time since last network update */
152 #endif /* __APPLE__ */
154 int launchd_idle_exit
;
155 /* Idle exit on select timeout? */
156 #endif /* HAVE_LAUNCHD */
161 * Check for setuid invocation, which we do not support!
164 if (getuid() != geteuid())
166 fputs("cupsd: Cannot run as a setuid program!\n", stderr
);
169 #endif /* HAVE_GETEUID */
172 * Check for command-line arguments...
178 if (getenv("CUPSD_LAUNCHD"))
183 #endif /* HAVE_LAUNCHD */
185 for (i
= 1; i
< argc
; i
++)
186 if (argv
[i
][0] == '-')
187 for (opt
= argv
[i
] + 1; *opt
!= '\0'; opt
++)
191 case 'C' : /* Run as child with config file */
194 #endif /* __APPLE__ */
196 case 'c' : /* Configuration file */
200 _cupsLangPuts(stderr
, _("cupsd: Expected config filename "
201 "after \"-c\" option!\n"));
205 if (argv
[i
][0] == '/')
208 * Absolute directory...
211 cupsdSetString(&ConfigurationFile
, argv
[i
]);
216 * Relative directory...
219 char *current
; /* Current directory */
223 * Allocate a buffer for the current working directory to
224 * reduce run-time stack usage; this approximates the
225 * behavior of some implementations of getcwd() when they
226 * are passed a NULL pointer.
229 if ((current
= malloc(1024)) == NULL
)
231 _cupsLangPuts(stderr
,
232 _("cupsd: Unable to get current directory!\n"));
236 if (!getcwd(current
, 1024))
238 _cupsLangPuts(stderr
,
239 _("cupsd: Unable to get current directory!\n"));
244 cupsdSetStringf(&ConfigurationFile
, "%s/%s", current
, argv
[i
]);
249 case 'f' : /* Run in foreground... */
253 case 'F' : /* Run in foreground, but disconnect from terminal... */
257 case 'h' : /* Show usage/help */
261 case 'l' : /* Started by launchd... */
266 _cupsLangPuts(stderr
, _("cupsd: launchd(8) support not compiled "
267 "in, running in normal mode.\n"));
269 #endif /* HAVE_LAUNCHD */
272 case 'p' : /* Stop immediately for profiling */
273 puts("Warning: -p option is for internal testing use only!");
278 case 't' : /* Test the cupsd.conf file... */
283 default : /* Unknown option */
284 _cupsLangPrintf(stderr
, _("cupsd: Unknown option \"%c\" - "
285 "aborting!\n"), *opt
);
291 _cupsLangPrintf(stderr
, _("cupsd: Unknown argument \"%s\" - aborting!\n"),
296 if (!ConfigurationFile
)
297 cupsdSetString(&ConfigurationFile
, CUPS_SERVERROOT
"/cupsd.conf");
300 * If the user hasn't specified "-f", run in the background...
306 * Setup signal handlers for the parent...
309 #ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */
310 sigset(SIGUSR1
, parent_handler
);
311 sigset(SIGCHLD
, parent_handler
);
313 sigset(SIGHUP
, SIG_IGN
);
314 #elif defined(HAVE_SIGACTION)
315 memset(&action
, 0, sizeof(action
));
316 sigemptyset(&action
.sa_mask
);
317 sigaddset(&action
.sa_mask
, SIGUSR1
);
318 action
.sa_handler
= parent_handler
;
319 sigaction(SIGUSR1
, &action
, NULL
);
320 sigaction(SIGCHLD
, &action
, NULL
);
322 sigemptyset(&action
.sa_mask
);
323 action
.sa_handler
= SIG_IGN
;
324 sigaction(SIGHUP
, &action
, NULL
);
326 signal(SIGUSR1
, parent_handler
);
327 signal(SIGCLD
, parent_handler
);
329 signal(SIGHUP
, SIG_IGN
);
330 #endif /* HAVE_SIGSET */
335 * OK, wait for the child to startup and send us SIGUSR1 or to crash
336 * and the OS send us SIGCHLD... We also need to ignore SIGHUP which
337 * might be sent by the init script to restart the scheduler...
340 for (; parent_signal
== 0;)
343 if (parent_signal
== SIGUSR1
)
351 else if (WIFEXITED(i
))
353 fprintf(stderr
, "cupsd: Child exited with status %d!\n",
359 fprintf(stderr
, "cupsd: Child exited on signal %d!\n", WTERMSIG(i
));
366 * Since CoreFoundation has an overly-agressive check for whether a
367 * process has forked but not exec'd (whether CF has been called or
368 * not...), we now have to exec ourselves with the "-f" option to
369 * eliminate their bogus warning messages.
372 execlp(argv
[0], argv
[0], "-C", ConfigurationFile
, (char *)0);
374 #endif /* __APPLE__ */
380 * Make sure we aren't tying up any filesystems...
387 * Disable core dumps...
390 getrlimit(RLIMIT_CORE
, &limit
);
392 setrlimit(RLIMIT_CORE
, &limit
);
395 * Disconnect from the controlling terminal...
401 * Close all open files...
404 getrlimit(RLIMIT_NOFILE
, &limit
);
406 for (i
= 0; i
< limit
.rlim_cur
&& i
< 1024; i
++)
410 * Redirect stdin/out/err to /dev/null...
413 open("/dev/null", O_RDONLY
);
414 open("/dev/null", O_WRONLY
);
415 open("/dev/null", O_WRONLY
);
420 * Set the timezone info...
426 setlocale(LC_TIME
, "");
430 * Set the maximum number of files...
433 getrlimit(RLIMIT_NOFILE
, &limit
);
435 #if !defined(HAVE_POLL) && !defined(HAVE_EPOLL) && !defined(HAVE_KQUEUE)
436 if (limit
.rlim_max
> FD_SETSIZE
)
439 #endif /* !HAVE_POLL && !HAVE_EPOLL && !HAVE_KQUEUE */
441 if (limit
.rlim_max
== RLIM_INFINITY
)
444 #endif /* RLIM_INFINITY */
445 MaxFDs
= limit
.rlim_max
;
447 limit
.rlim_cur
= MaxFDs
;
449 setrlimit(RLIMIT_NOFILE
, &limit
);
454 * Read configuration...
457 if (!cupsdReadConfiguration())
460 printf("%s contains errors\n", ConfigurationFile
);
462 syslog(LOG_LPR
, "Unable to read configuration file \'%s\' - exiting!",
466 else if (TestConfigFile
)
468 printf("%s is OK\n", ConfigurationFile
);
472 if (!strncmp(TempDir
, RequestRoot
, strlen(RequestRoot
)))
475 * Clean out the temporary directory...
478 cups_dir_t
*dir
; /* Temporary directory */
479 cups_dentry_t
*dent
; /* Directory entry */
480 char tempfile
[1024]; /* Temporary filename */
483 if ((dir
= cupsDirOpen(TempDir
)) != NULL
)
485 cupsdLogMessage(CUPSD_LOG_INFO
,
486 "Cleaning out old temporary files in \"%s\"...", TempDir
);
488 while ((dent
= cupsDirRead(dir
)) != NULL
)
490 snprintf(tempfile
, sizeof(tempfile
), "%s/%s", TempDir
, dent
->filename
);
492 if (unlink(tempfile
))
493 cupsdLogMessage(CUPSD_LOG_ERROR
,
494 "Unable to remove temporary file \"%s\" - %s",
495 tempfile
, strerror(errno
));
497 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Removed temporary file \"%s\"...",
504 cupsdLogMessage(CUPSD_LOG_ERROR
,
505 "Unable to open temporary directory \"%s\" - %s",
506 TempDir
, strerror(errno
));
513 * If we were started by launchd get the listen sockets file descriptors...
518 #endif /* HAVE_LAUNCHD */
520 #if defined(__APPLE__) && defined(HAVE_DLFCN_H)
522 * Load Print Service quota enforcement library (X Server only)
525 PSQLibRef
= dlopen(PSQLibPath
, RTLD_LAZY
);
528 PSQUpdateQuotaProc
= dlsym(PSQLibRef
, PSQLibFuncName
);
529 #endif /* __APPLE__ && HAVE_DLFCN_H */
534 * If the weak-linked GSSAPI/Kerberos library is not present, don't try
538 if (krb5_init_context
!= NULL
)
539 # endif /* __APPLE__ */
542 * Setup a Kerberos context for the scheduler to use...
545 if (krb5_init_context(&KerberosContext
))
547 KerberosContext
= NULL
;
549 cupsdLogMessage(CUPSD_LOG_ERROR
, "Unable to initialize Kerberos context");
551 #endif /* HAVE_GSSAPI */
554 * Startup the server...
560 * Catch hangup and child signals and ignore broken pipes...
563 #ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */
564 sigset(SIGCHLD
, sigchld_handler
);
565 sigset(SIGHUP
, sighup_handler
);
566 sigset(SIGPIPE
, SIG_IGN
);
567 sigset(SIGTERM
, sigterm_handler
);
568 #elif defined(HAVE_SIGACTION)
569 memset(&action
, 0, sizeof(action
));
571 sigemptyset(&action
.sa_mask
);
572 sigaddset(&action
.sa_mask
, SIGTERM
);
573 sigaddset(&action
.sa_mask
, SIGCHLD
);
574 action
.sa_handler
= sigchld_handler
;
575 sigaction(SIGCHLD
, &action
, NULL
);
577 sigemptyset(&action
.sa_mask
);
578 sigaddset(&action
.sa_mask
, SIGHUP
);
579 action
.sa_handler
= sighup_handler
;
580 sigaction(SIGHUP
, &action
, NULL
);
582 sigemptyset(&action
.sa_mask
);
583 action
.sa_handler
= SIG_IGN
;
584 sigaction(SIGPIPE
, &action
, NULL
);
586 sigemptyset(&action
.sa_mask
);
587 sigaddset(&action
.sa_mask
, SIGTERM
);
588 sigaddset(&action
.sa_mask
, SIGCHLD
);
589 action
.sa_handler
= sigterm_handler
;
590 sigaction(SIGTERM
, &action
, NULL
);
592 signal(SIGCLD
, sigchld_handler
); /* No, SIGCLD isn't a typo... */
593 signal(SIGHUP
, sighup_handler
);
594 signal(SIGPIPE
, SIG_IGN
);
595 signal(SIGTERM
, sigterm_handler
);
596 #endif /* HAVE_SIGSET */
600 * Try to create a fake lpsched lock file if one is not already there.
601 * Some Adobe applications need it under IRIX in order to enable
605 if ((fp
= cupsFileOpen("/var/spool/lp/SCHEDLOCK", "w")) == NULL
)
607 syslog(LOG_LPR
, "Unable to create fake lpsched lock file "
608 "\"/var/spool/lp/SCHEDLOCK\"\' - %s!",
613 fchmod(cupsFileNumber(fp
), 0644);
614 fchown(cupsFileNumber(fp
), User
, Group
);
621 * Initialize authentication certificates...
627 * If we are running in the background, signal the parent process that
628 * we are up and running...
632 if (!fg
|| run_as_child
)
635 #endif /* __APPLE__ */
638 * Send a signal to the parent process, but only if the parent is
639 * not PID 1 (init). This avoids accidentally shutting down the
640 * system on OpenBSD if you CTRL-C the server before it is up...
643 i
= getppid(); /* Save parent PID to avoid race condition */
651 * Start power management framework...
654 cupsdStartSystemMonitor();
655 #endif /* __APPLE__ */
658 * Start any pending print jobs...
667 current_time
= time(NULL
);
668 browse_time
= current_time
;
669 event_time
= current_time
;
670 expire_time
= current_time
;
673 senddoc_time
= current_time
;
675 while (!stop_scheduler
)
678 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
679 "main: Top of loop, dead_children=%d, NeedReload=%d",
680 dead_children
, NeedReload
);
684 * Check if there are dead children to handle...
691 * Check if we need to load the server configuration file...
697 * Close any idle clients...
700 if (cupsArrayCount(Clients
) > 0)
702 for (con
= (cupsd_client_t
*)cupsArrayFirst(Clients
);
704 con
= (cupsd_client_t
*)cupsArrayNext(Clients
))
705 if (con
->http
.state
== HTTP_WAITING
)
706 cupsdCloseClient(con
);
708 con
->http
.keep_alive
= HTTP_KEEPALIVE_OFF
;
710 cupsdPauseListening();
714 * Check for any active jobs...
717 for (job
= (cupsd_job_t
*)cupsArrayFirst(ActiveJobs
);
719 job
= (cupsd_job_t
*)cupsArrayNext(ActiveJobs
))
720 if (job
->state_value
== IPP_JOB_PROCESSING
)
724 * Restart if all clients are closed and all jobs finished, or
725 * if the reload timeout has elapsed...
728 if ((cupsArrayCount(Clients
) == 0 &&
729 (!job
|| NeedReload
!= RELOAD_ALL
)) ||
730 (time(NULL
) - ReloadTime
) >= ReloadTimeout
)
733 * Shutdown the server...
739 * Read configuration...
742 if (!cupsdReadConfiguration())
744 syslog(LOG_LPR
, "Unable to read configuration file \'%s\' - exiting!",
753 * If we were started by launchd get the listen sockets file descriptors...
758 #endif /* HAVE_LAUNCHD */
761 * Startup the server...
769 * Check for available input or ready output. If cupsdDoSelect()
770 * returns 0 or -1, something bad happened and we should exit
773 * Note that we at least have one listening socket open at all
777 if ((timeout
= select_timeout(fds
)) > 1 && LastEvent
)
782 * If no other work is scheduled and we're being controlled by
783 * launchd then timeout after 'LaunchdTimeout' seconds of
787 if (timeout
== 86400 && Launchd
&& LaunchdTimeout
&& !NumPolled
&&
788 !cupsArrayCount(ActiveJobs
) &&
790 (!BrowseRemoteProtocols
&&
791 (!NumBrowsers
|| !BrowseLocalProtocols
||
792 cupsArrayCount(Printers
) == 0))))
794 timeout
= LaunchdTimeout
;
795 launchd_idle_exit
= 1;
798 launchd_idle_exit
= 0;
799 #endif /* HAVE_LAUNCHD */
801 if ((fds
= cupsdDoSelect(timeout
)) < 0)
804 * Got an error from select!
808 cupsd_printer_t
*p
; /* Current printer */
809 #endif /* HAVE_DNSSD */
812 if (errno
== EINTR
) /* Just interrupted by a signal */
816 * Log all sorts of debug info to help track down the problem.
819 cupsdLogMessage(CUPSD_LOG_EMERG
, "cupsdDoSelect() failed - %s!",
822 for (i
= 0, con
= (cupsd_client_t
*)cupsArrayFirst(Clients
);
824 i
++, con
= (cupsd_client_t
*)cupsArrayNext(Clients
))
825 cupsdLogMessage(CUPSD_LOG_EMERG
,
826 "Clients[%d] = %d, file = %d, state = %d",
827 i
, con
->http
.fd
, con
->file
, con
->http
.state
);
829 for (i
= 0, lis
= (cupsd_listener_t
*)cupsArrayFirst(Listeners
);
831 i
++, lis
= (cupsd_listener_t
*)cupsArrayNext(Listeners
))
832 cupsdLogMessage(CUPSD_LOG_EMERG
, "Listeners[%d] = %d", i
, lis
->fd
);
834 cupsdLogMessage(CUPSD_LOG_EMERG
, "BrowseSocket = %d", BrowseSocket
);
836 cupsdLogMessage(CUPSD_LOG_EMERG
, "CGIPipes[0] = %d", CGIPipes
[0]);
839 cupsdLogMessage(CUPSD_LOG_EMERG
, "SysEventPipes[0] = %d",
841 #endif /* __APPLE__ */
843 for (job
= (cupsd_job_t
*)cupsArrayFirst(ActiveJobs
);
845 job
= (cupsd_job_t
*)cupsArrayNext(ActiveJobs
))
846 cupsdLogMessage(CUPSD_LOG_EMERG
, "Jobs[%d] = %d < [%d %d] > [%d %d]",
848 job
->status_buffer
? job
->status_buffer
->fd
: -1,
849 job
->print_pipes
[0], job
->print_pipes
[1],
850 job
->back_pipes
[0], job
->back_pipes
[1]);
853 for (p
= (cupsd_printer_t
*)cupsArrayFirst(Printers
);
855 p
= (cupsd_printer_t
*)cupsArrayNext(Printers
))
856 cupsdLogMessage(CUPSD_LOG_EMERG
, "printer[%s] reg_name=\"%s\"", p
->name
,
857 p
->reg_name
? p
->reg_name
: "(null)");
858 #endif /* HAVE_DNSSD */
863 current_time
= time(NULL
);
866 * Write dirty config/state files...
869 if (DirtyCleanTime
&& current_time
>= DirtyCleanTime
)
877 * Update the network interfaces once a minute...
880 if ((current_time
- netif_time
) >= 60)
882 netif_time
= current_time
;
885 #endif /* !__APPLE__ */
889 * If no other work was scheduled and we're being controlled by launchd
890 * then timeout after 'LaunchdTimeout' seconds of inactivity...
893 if (!fds
&& launchd_idle_exit
)
895 cupsdLogMessage(CUPSD_LOG_INFO
,
896 "Printer sharing is off and there are no jobs pending, "
897 "will restart on demand.");
901 #endif /* HAVE_LAUNCHD */
904 * Resume listening for new connections as needed...
907 if (ListeningPaused
&& ListeningPaused
<= current_time
&&
908 cupsArrayCount(Clients
) < MaxClients
)
909 cupsdResumeListening();
912 * Expire subscriptions and unload completed jobs as needed...
915 if (current_time
> expire_time
)
917 if (cupsArrayCount(Subscriptions
) > 0)
918 cupsdExpireSubscriptions(NULL
, NULL
);
920 cupsdUnloadCompletedJobs();
922 expire_time
= current_time
;
926 * Update the browse list as needed...
932 if ((BrowseRemoteProtocols
& BROWSE_SLP
) &&
933 BrowseSLPRefresh
<= current_time
)
934 cupsdUpdateSLPBrowse();
935 #endif /* HAVE_LIBSLP */
938 if ((BrowseRemoteProtocols
& BROWSE_LDAP
) &&
939 BrowseLDAPRefresh
<= current_time
)
940 cupsdUpdateLDAPBrowse();
941 #endif /* HAVE_LDAP */
944 if (Browsing
&& current_time
> browse_time
)
946 cupsdSendBrowseList();
947 browse_time
= current_time
;
951 * Update the root certificate once every 5 minutes if we have client
955 if ((current_time
- RootCertTime
) >= RootCertDuration
&& RootCertDuration
&&
956 !RunUser
&& cupsArrayCount(Clients
))
959 * Update the root certificate...
963 cupsdAddCert(0, "root", NULL
);
967 * Check for new data on the client sockets...
970 for (con
= (cupsd_client_t
*)cupsArrayFirst(Clients
);
972 con
= (cupsd_client_t
*)cupsArrayNext(Clients
))
975 * Process pending data in the input buffer...
980 cupsdReadClient(con
);
985 * Check the activity and close old clients...
988 activity
= current_time
- Timeout
;
989 if (con
->http
.activity
< activity
&& !con
->pipe_pid
)
991 cupsdLogMessage(CUPSD_LOG_DEBUG
,
992 "Closing client %d after %d seconds of inactivity...",
993 con
->http
.fd
, Timeout
);
995 cupsdCloseClient(con
);
1001 * Update any pending multi-file documents...
1004 if ((current_time
- senddoc_time
) >= 10)
1007 senddoc_time
= current_time
;
1011 * Log statistics at most once a minute when in debug mode...
1014 if ((current_time
- report_time
) >= 60 && LogLevel
>= CUPSD_LOG_DEBUG
)
1016 size_t string_count
, /* String count */
1017 alloc_bytes
, /* Allocated string bytes */
1018 total_bytes
; /* Total string bytes */
1019 #ifdef HAVE_MALLINFO
1020 struct mallinfo mem
; /* Malloc information */
1024 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Report: malloc-arena=%lu", mem
.arena
);
1025 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Report: malloc-used=%lu",
1026 mem
.usmblks
+ mem
.uordblks
);
1027 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Report: malloc-free=%lu",
1028 mem
.fsmblks
+ mem
.fordblks
);
1029 #endif /* HAVE_MALLINFO */
1031 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Report: clients=%d",
1032 cupsArrayCount(Clients
));
1033 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Report: jobs=%d",
1034 cupsArrayCount(Jobs
));
1035 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Report: jobs-active=%d",
1036 cupsArrayCount(ActiveJobs
));
1037 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Report: printers=%d",
1038 cupsArrayCount(Printers
));
1039 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Report: printers-implicit=%d",
1040 cupsArrayCount(ImplicitPrinters
));
1042 string_count
= _cupsStrStatistics(&alloc_bytes
, &total_bytes
);
1043 cupsdLogMessage(CUPSD_LOG_DEBUG
,
1044 "Report: stringpool-string-count=" CUPS_LLFMT
,
1045 CUPS_LLCAST string_count
);
1046 cupsdLogMessage(CUPSD_LOG_DEBUG
,
1047 "Report: stringpool-alloc-bytes=" CUPS_LLFMT
,
1048 CUPS_LLCAST alloc_bytes
);
1049 cupsdLogMessage(CUPSD_LOG_DEBUG
,
1050 "Report: stringpool-total-bytes=" CUPS_LLFMT
,
1051 CUPS_LLCAST total_bytes
);
1053 report_time
= current_time
;
1057 * Handle OS-specific event notification for any events that have
1058 * accumulated. Don't send these more than once a second...
1061 if (LastEvent
&& (current_time
- event_time
) >= 1)
1063 #ifdef HAVE_NOTIFY_POST
1064 if (LastEvent
& (CUPSD_EVENT_PRINTER_ADDED
|
1065 CUPSD_EVENT_PRINTER_DELETED
|
1066 CUPSD_EVENT_PRINTER_MODIFIED
))
1068 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1069 "notify_post(\"com.apple.printerListChange\")");
1070 notify_post("com.apple.printerListChange");
1073 if (LastEvent
& CUPSD_EVENT_PRINTER_STATE_CHANGED
)
1075 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1076 "notify_post(\"com.apple.printerHistoryChange\")");
1077 notify_post("com.apple.printerHistoryChange");
1080 if (LastEvent
& (CUPSD_EVENT_JOB_STATE_CHANGED
|
1081 CUPSD_EVENT_JOB_CONFIG_CHANGED
|
1082 CUPSD_EVENT_JOB_PROGRESS
))
1084 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1085 "notify_post(\"com.apple.jobChange\")");
1086 notify_post("com.apple.jobChange");
1088 #endif /* HAVE_NOTIFY_POST */
1091 * Reset the accumulated events...
1094 LastEvent
= CUPSD_EVENT_NONE
;
1095 event_time
= current_time
;
1100 * Log a message based on what happened...
1104 cupsdLogMessage(CUPSD_LOG_INFO
, "Scheduler shutting down normally.");
1106 cupsdLogMessage(CUPSD_LOG_ERROR
,
1107 "Scheduler shutting down due to program error.");
1110 * Close all network clients...
1117 * Update the launchd KeepAlive file as needed...
1122 #endif /* HAVE_LAUNCHD */
1132 * Stop monitoring system event monitoring...
1135 cupsdStopSystemMonitor();
1136 #endif /* __APPLE__ */
1140 * Free the scheduler's Kerberos context...
1145 * If the weak-linked GSSAPI/Kerberos library is not present, don't try
1149 if (krb5_init_context
!= NULL
)
1150 # endif /* __APPLE__ */
1151 if (KerberosContext
)
1152 krb5_free_context(KerberosContext
);
1153 #endif /* HAVE_GSSAPI */
1158 * Unload Print Service quota enforcement library (X Server only)
1161 PSQUpdateQuotaProc
= NULL
;
1167 #endif /* HAVE_DLFCN_H */
1168 #endif /* __APPLE__ */
1172 * Remove the fake IRIX lpsched lock file, but only if the existing
1173 * file is not a FIFO which indicates that the real IRIX lpsched is
1177 if (!stat("/var/spool/lp/FIFO", &statbuf
))
1178 if (!S_ISFIFO(statbuf
.st_mode
))
1179 unlink("/var/spool/lp/SCHEDLOCK");
1184 return (!stop_scheduler
);
1189 * 'cupsdClosePipe()' - Close a pipe as necessary.
1193 cupsdClosePipe(int *fds
) /* I - Pipe file descriptors (2) */
1196 * Close file descriptors as needed...
1214 * 'cupsdOpenPipe()' - Create a pipe which is closed on exec.
1217 int /* O - 0 on success, -1 on error */
1218 cupsdOpenPipe(int *fds
) /* O - Pipe file descriptors (2) */
1221 * Create the pipe...
1233 * Set the "close on exec" flag on each end of the pipe...
1236 if (fcntl(fds
[0], F_SETFD
, fcntl(fds
[0], F_GETFD
) | FD_CLOEXEC
))
1247 if (fcntl(fds
[1], F_SETFD
, fcntl(fds
[1], F_GETFD
) | FD_CLOEXEC
))
1259 * Return 0 indicating success...
1267 * 'cupsdClearString()' - Clear a string.
1271 cupsdClearString(char **s
) /* O - String value */
1282 * 'cupsdHoldSignals()' - Hold child and termination signals.
1286 cupsdHoldSignals(void)
1288 #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
1289 sigset_t newmask
; /* New POSIX signal mask */
1290 #endif /* HAVE_SIGACTION && !HAVE_SIGSET */
1300 #elif defined(HAVE_SIGACTION)
1301 sigemptyset(&newmask
);
1302 sigaddset(&newmask
, SIGTERM
);
1303 sigaddset(&newmask
, SIGCHLD
);
1304 sigprocmask(SIG_BLOCK
, &newmask
, &holdmask
);
1305 #endif /* HAVE_SIGSET */
1310 * 'cupsdReleaseSignals()' - Release signals for delivery.
1314 cupsdReleaseSignals(void)
1323 #elif defined(HAVE_SIGACTION)
1324 sigprocmask(SIG_SETMASK
, &holdmask
, NULL
);
1325 #endif /* HAVE_SIGSET */
1330 * 'cupsdSetString()' - Set a string value.
1334 cupsdSetString(char **s
, /* O - New string */
1335 const char *v
) /* I - String value */
1344 *s
= _cupsStrAlloc(v
);
1351 * 'cupsdSetStringf()' - Set a formatted string value.
1355 cupsdSetStringf(char **s
, /* O - New string */
1356 const char *f
, /* I - Printf-style format string */
1357 ...) /* I - Additional args as needed */
1359 char v
[4096]; /* Formatting string value */
1360 va_list ap
; /* Argument pointer */
1361 char *olds
; /* Old string */
1372 vsnprintf(v
, sizeof(v
), f
, ap
);
1375 *s
= _cupsStrAlloc(v
);
1387 * 'launchd_checkin()' - Check-in with launchd and collect the listening fds.
1391 launchd_checkin(void)
1393 int i
, /* Looping var */
1394 count
, /* Numebr of listeners */
1395 portnum
; /* Port number */
1396 launch_data_t ld_msg
, /* Launch data message */
1397 ld_resp
, /* Launch data response */
1398 ld_array
, /* Launch data array */
1399 ld_sockets
, /* Launch data sockets dictionary */
1400 tmp
; /* Launch data */
1401 cupsd_listener_t
*lis
; /* Listeners array */
1402 http_addr_t addr
; /* Address variable */
1403 socklen_t addrlen
; /* Length of address */
1404 int fd
; /* File descriptor */
1405 char s
[256]; /* String addresss */
1408 cupsdLogMessage(CUPSD_LOG_DEBUG
, "launchd_checkin: pid=%d", (int)getpid());
1411 * Check-in with launchd...
1414 ld_msg
= launch_data_new_string(LAUNCH_KEY_CHECKIN
);
1415 if ((ld_resp
= launch_msg(ld_msg
)) == NULL
)
1417 cupsdLogMessage(CUPSD_LOG_ERROR
,
1418 "launchd_checkin: launch_msg(\"" LAUNCH_KEY_CHECKIN
1421 return; /* anti-compiler-warning */
1424 if (launch_data_get_type(ld_resp
) == LAUNCH_DATA_ERRNO
)
1426 errno
= launch_data_get_errno(ld_resp
);
1427 cupsdLogMessage(CUPSD_LOG_ERROR
, "launchd_checkin: Check-in failed: %s",
1430 return; /* anti-compiler-warning */
1434 * Get the sockets dictionary...
1437 if ((ld_sockets
= launch_data_dict_lookup(ld_resp
, LAUNCH_JOBKEY_SOCKETS
))
1440 cupsdLogMessage(CUPSD_LOG_ERROR
,
1441 "launchd_checkin: No sockets found to answer requests on!");
1443 return; /* anti-compiler-warning */
1447 * Get the array of listener sockets...
1450 if ((ld_array
= launch_data_dict_lookup(ld_sockets
, "Listeners")) == NULL
)
1452 cupsdLogMessage(CUPSD_LOG_ERROR
,
1453 "launchd_checkin: No sockets found to answer requests on!");
1455 return; /* anti-compiler-warning */
1459 * Add listening fd(s) to the Listener array...
1462 if (launch_data_get_type(ld_array
) == LAUNCH_DATA_ARRAY
)
1464 count
= launch_data_array_get_count(ld_array
);
1466 for (i
= 0; i
< count
; i
++)
1469 * Get the launchd file descriptor and address...
1472 if ((tmp
= launch_data_array_get_index(ld_array
, i
)) != NULL
)
1474 fd
= launch_data_get_fd(tmp
);
1475 addrlen
= sizeof(addr
);
1477 if (getsockname(fd
, (struct sockaddr
*)&addr
, &addrlen
))
1479 cupsdLogMessage(CUPSD_LOG_ERROR
,
1480 "launchd_checkin: Unable to get local address - %s",
1486 * Try to match the launchd socket address to one of the listeners...
1489 for (lis
= (cupsd_listener_t
*)cupsArrayFirst(Listeners
);
1491 lis
= (cupsd_listener_t
*)cupsArrayNext(Listeners
))
1492 if (httpAddrEqual(&lis
->address
, &addr
))
1496 * Add a new listener If there's no match...
1501 cupsdLogMessage(CUPSD_LOG_DEBUG
,
1502 "launchd_checkin: Matched existing listener %s with fd %d...",
1503 httpAddrString(&(lis
->address
), s
, sizeof(s
)), fd
);
1507 cupsdLogMessage(CUPSD_LOG_DEBUG
,
1508 "launchd_checkin: Adding new listener %s with fd %d...",
1509 httpAddrString(&addr
, s
, sizeof(s
)), fd
);
1511 if ((lis
= calloc(1, sizeof(cupsd_listener_t
))) == NULL
)
1513 cupsdLogMessage(CUPSD_LOG_ERROR
,
1514 "launchd_checkin: Unable to allocate listener - %s.",
1519 cupsArrayAdd(Listeners
, lis
);
1521 memcpy(&lis
->address
, &addr
, sizeof(lis
->address
));
1530 if (lis
->address
.addr
.sa_family
== AF_INET6
)
1531 portnum
= ntohs(lis
->address
.ipv6
.sin6_port
);
1533 # endif /* AF_INET6 */
1534 if (lis
->address
.addr
.sa_family
== AF_INET
)
1535 portnum
= ntohs(lis
->address
.ipv4
.sin_port
);
1538 lis
->encryption
= HTTP_ENCRYPT_ALWAYS
;
1539 # endif /* HAVE_SSL */
1544 launch_data_free(ld_msg
);
1545 launch_data_free(ld_resp
);
1550 * 'launchd_checkout()' - Update the launchd KeepAlive file as needed.
1554 launchd_checkout(void)
1556 int fd
; /* File descriptor */
1560 * Create or remove the launchd KeepAlive file based on whether
1561 * there are active jobs, polling, browsing for remote printers or
1562 * shared printers to advertise...
1565 if ((cupsArrayCount(ActiveJobs
) || NumPolled
||
1567 (BrowseRemoteProtocols
||
1568 (BrowseLocalProtocols
&& NumBrowsers
&& cupsArrayCount(Printers
))))))
1570 cupsdLogMessage(CUPSD_LOG_DEBUG
,
1571 "Creating launchd keepalive file \"" CUPS_KEEPALIVE
"\"...");
1573 if ((fd
= open(CUPS_KEEPALIVE
, O_RDONLY
| O_CREAT
| O_EXCL
, S_IRUSR
)) >= 0)
1578 cupsdLogMessage(CUPSD_LOG_DEBUG
,
1579 "Removing launchd keepalive file \"" CUPS_KEEPALIVE
"\"...");
1581 unlink(CUPS_KEEPALIVE
);
1584 #endif /* HAVE_LAUNCHD */
1588 * 'parent_handler()' - Catch USR1/CHLD signals...
1592 parent_handler(int sig
) /* I - Signal */
1595 * Store the signal we got from the OS and return...
1598 parent_signal
= sig
;
1603 * 'process_children()' - Process all dead children...
1607 process_children(void)
1609 int status
; /* Exit status of child */
1610 int pid
; /* Process ID of child */
1611 cupsd_job_t
*job
; /* Current job */
1612 int i
; /* Looping var */
1613 char name
[1024]; /* Process name */
1616 cupsdLogMessage(CUPSD_LOG_DEBUG2
, "process_children()");
1619 * Reset the dead_children flag...
1625 * Collect the exit status of some children...
1629 while ((pid
= waitpid(-1, &status
, WNOHANG
)) > 0)
1630 #elif defined(HAVE_WAIT3)
1631 while ((pid
= wait3(&status
, WNOHANG
, NULL
)) > 0)
1633 if ((pid
= wait(&status
)) > 0)
1634 #endif /* HAVE_WAITPID */
1637 * Ignore SIGTERM errors - that comes when a job is canceled...
1640 cupsdFinishProcess(pid
, name
, sizeof(name
));
1643 * Delete certificates for CGI processes...
1647 cupsdDeleteCert(pid
);
1650 * Lookup the PID in the jobs list...
1653 for (job
= (cupsd_job_t
*)cupsArrayFirst(ActiveJobs
);
1655 job
= (cupsd_job_t
*)cupsArrayNext(ActiveJobs
))
1656 if (job
->state_value
>= IPP_JOB_HELD
&& (job
->filters
[0] || job
->backend
))
1658 for (i
= 0; job
->filters
[i
]; i
++)
1659 if (job
->filters
[i
] == pid
)
1662 if (job
->filters
[i
] || job
->backend
== pid
)
1665 * OK, this process has gone away; what's left?
1668 if (job
->filters
[i
])
1669 job
->filters
[i
] = -pid
;
1671 job
->backend
= -pid
;
1673 if (status
&& job
->status
>= 0)
1676 * An error occurred; save the exit status so we know to stop
1677 * the printer or cancel the job when all of the filters finish...
1679 * A negative status indicates that the backend failed and the
1680 * printer needs to be stopped.
1683 if (job
->filters
[i
])
1684 job
->status
= status
; /* Filter failed */
1686 job
->status
= -status
; /* Backend failed */
1688 if (job
->printer
&& !(job
->printer
->type
& CUPS_PRINTER_FAX
) &&
1689 job
->status_level
> CUPSD_LOG_ERROR
)
1691 job
->status_level
= CUPSD_LOG_ERROR
;
1693 snprintf(job
->printer
->state_message
,
1694 sizeof(job
->printer
->state_message
), "%s failed", name
);
1695 cupsdAddPrinterHistory(job
->printer
);
1700 * If this is not the last file in a job, see if all of the
1701 * filters are done, and if so move to the next file.
1704 if (job
->current_file
< job
->num_files
)
1706 for (i
= 0; job
->filters
[i
] < 0; i
++);
1708 if (!job
->filters
[i
])
1711 * Process the next file...
1714 cupsdFinishJob(job
);
1722 * Show the exit status as needed...
1725 if (status
== SIGTERM
)
1730 if (WIFEXITED(status
))
1731 cupsdLogMessage(CUPSD_LOG_DEBUG
, "PID %d (%s) stopped with status %d!",
1732 pid
, name
, WEXITSTATUS(status
));
1734 cupsdLogMessage(CUPSD_LOG_ERROR
, "PID %d (%s) crashed on signal %d!",
1735 pid
, name
, WTERMSIG(status
));
1737 if (LogLevel
< CUPSD_LOG_DEBUG
)
1738 cupsdLogMessage(CUPSD_LOG_INFO
,
1739 "Hint: Try setting the LogLevel to \"debug\" to find "
1743 cupsdLogMessage(CUPSD_LOG_DEBUG
, "PID %d (%s) exited with no errors.",
1750 * 'sigchld_handler()' - Handle 'child' signals from old processes.
1754 sigchld_handler(int sig
) /* I - Signal number */
1759 * Flag that we have dead children...
1765 * Reset the signal handler as needed...
1768 #if !defined(HAVE_SIGSET) && !defined(HAVE_SIGACTION)
1769 signal(SIGCLD
, sigchld_handler
);
1770 #endif /* !HAVE_SIGSET && !HAVE_SIGACTION */
1775 * 'sighup_handler()' - Handle 'hangup' signals to reconfigure the scheduler.
1779 sighup_handler(int sig
) /* I - Signal number */
1783 NeedReload
= RELOAD_ALL
;
1784 ReloadTime
= time(NULL
);
1786 #if !defined(HAVE_SIGSET) && !defined(HAVE_SIGACTION)
1787 signal(SIGHUP
, sighup_handler
);
1788 #endif /* !HAVE_SIGSET && !HAVE_SIGACTION */
1793 * 'sigterm_handler()' - Handle 'terminate' signals that stop the scheduler.
1797 sigterm_handler(int sig
) /* I - Signal number */
1799 (void)sig
; /* remove compiler warnings... */
1802 * Flag that we should stop and return...
1810 * 'select_timeout()' - Calculate the select timeout value.
1814 static long /* O - Number of seconds */
1815 select_timeout(int fds
) /* I - Number of descriptors returned */
1817 long timeout
; /* Timeout for select */
1818 time_t now
; /* Current time */
1819 cupsd_client_t
*con
; /* Client information */
1820 cupsd_printer_t
*p
; /* Printer information */
1821 cupsd_job_t
*job
; /* Job information */
1822 cupsd_subscription_t
*sub
; /* Subscription information */
1823 const char *why
; /* Debugging aid */
1827 * Check to see if any of the clients have pending data to be
1828 * processed; if so, the timeout should be 0...
1831 for (con
= (cupsd_client_t
*)cupsArrayFirst(Clients
);
1833 con
= (cupsd_client_t
*)cupsArrayNext(Clients
))
1834 if (con
->http
.used
> 0)
1838 * If select has been active in the last second (fds > 0) or we have
1839 * many resources in use then don't bother trying to optimize the
1840 * timeout, just make it 1 second.
1843 if (fds
> 0 || cupsArrayCount(Clients
) > 50)
1847 * Otherwise, check all of the possible events that we need to wake for...
1851 timeout
= now
+ 86400; /* 86400 == 1 day */
1855 * Check whether we are accepting new connections...
1858 if (ListeningPaused
> 0 && cupsArrayCount(Clients
) < MaxClients
&&
1859 ListeningPaused
< timeout
)
1861 if (ListeningPaused
<= now
)
1864 timeout
= ListeningPaused
;
1866 why
= "resume listening";
1870 * Check the activity and close old clients...
1873 for (con
= (cupsd_client_t
*)cupsArrayFirst(Clients
);
1875 con
= (cupsd_client_t
*)cupsArrayNext(Clients
))
1876 if ((con
->http
.activity
+ Timeout
) < timeout
)
1878 timeout
= con
->http
.activity
+ Timeout
;
1879 why
= "timeout a client connection";
1883 * Update the browse list as needed...
1886 if (Browsing
&& BrowseLocalProtocols
)
1889 if ((BrowseLocalProtocols
& BROWSE_SLP
) && (BrowseSLPRefresh
< timeout
))
1891 timeout
= BrowseSLPRefresh
;
1892 why
= "update SLP browsing";
1894 #endif /* HAVE_LIBSLP */
1897 if ((BrowseLocalProtocols
& BROWSE_LDAP
) && (BrowseLDAPRefresh
< timeout
))
1899 timeout
= BrowseLDAPRefresh
;
1900 why
= "update LDAP browsing";
1902 #endif /* HAVE_LDAP */
1904 if ((BrowseLocalProtocols
& BROWSE_CUPS
) && NumBrowsers
)
1906 for (p
= (cupsd_printer_t
*)cupsArrayFirst(Printers
);
1908 p
= (cupsd_printer_t
*)cupsArrayNext(Printers
))
1910 if (p
->type
& CUPS_PRINTER_REMOTE
)
1912 if ((p
->browse_time
+ BrowseTimeout
) < timeout
)
1914 timeout
= p
->browse_time
+ BrowseTimeout
;
1915 why
= "browse timeout a printer";
1918 else if (p
->shared
&& !(p
->type
& CUPS_PRINTER_IMPLICIT
))
1920 if (BrowseInterval
&& (p
->browse_time
+ BrowseInterval
) < timeout
)
1922 timeout
= p
->browse_time
+ BrowseInterval
;
1923 why
= "send browse update";
1931 * Check for any active jobs...
1934 if (DirtyCleanTime
&& timeout
> DirtyCleanTime
)
1936 timeout
= DirtyCleanTime
;
1937 why
= "write dirty config/state files";
1941 * Check for any active jobs...
1944 if (timeout
> (now
+ 10) && ActiveJobs
)
1946 for (job
= (cupsd_job_t
*)cupsArrayFirst(ActiveJobs
);
1948 job
= (cupsd_job_t
*)cupsArrayNext(ActiveJobs
))
1949 if (job
->state_value
<= IPP_JOB_PROCESSING
)
1952 why
= "process active jobs";
1957 #ifdef HAVE_MALLINFO
1959 * Log memory usage every minute...
1962 if (LogLevel
>= CUPSD_LOG_DEBUG
&& (mallinfo_time
+ 60) < timeout
)
1964 timeout
= mallinfo_time
+ 60;
1965 why
= "display memory usage";
1967 #endif /* HAVE_MALLINFO */
1970 * Expire subscriptions as needed...
1973 for (sub
= (cupsd_subscription_t
*)cupsArrayFirst(Subscriptions
);
1975 sub
= (cupsd_subscription_t
*)cupsArrayNext(Subscriptions
))
1976 if (!sub
->job
&& sub
->expire
&& sub
->expire
< timeout
)
1978 timeout
= sub
->expire
;
1979 why
= "expire subscription";
1983 * Adjust from absolute to relative time. If p->browse_time above
1984 * was 0 then we can end up with a negative value here, so check.
1985 * We add 1 second to the timeout since events occur after the
1986 * timeout expires, and limit the timeout to 86400 seconds (1 day)
1987 * to avoid select() timeout limits present on some operating
1991 timeout
= timeout
- now
+ 1;
1995 else if (timeout
> 86400)
1999 * Log and return the timeout value...
2002 cupsdLogMessage(CUPSD_LOG_DEBUG2
, "select_timeout(%d): %ld seconds to %s",
2010 * 'usage()' - Show scheduler usage.
2014 usage(int status
) /* O - Exit status */
2016 _cupsLangPuts(status
? stderr
: stdout
,
2017 _("Usage: cupsd [-c config-file] [-f] [-F] [-h] [-l]\n"
2019 "-c config-file Load alternate configuration file\n"
2020 "-f Run in the foreground\n"
2021 "-F Run in the foreground but detach\n"
2022 "-h Show this usage message\n"
2023 "-l Run cupsd from launchd(8)\n"));
2029 * End of "$Id: main.c 7681 2008-06-20 21:06:02Z mike $".