2 * "$Id: main.c 7925 2008-09-10 17:47:26Z mike $"
4 * Main loop for the CUPS scheduler.
6 * Copyright 2007-2012 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 * cupsdAddString() - Copy and add a string to an array.
19 * cupsdCheckProcess() - Tell the main loop to check for dead children.
20 * cupsdClearString() - Clear a string.
21 * cupsdFreeStrings() - Free an array of strings.
22 * cupsdHoldSignals() - Hold child and termination signals.
23 * cupsdReleaseSignals() - Release signals for delivery.
24 * cupsdSetString() - Set a string value.
25 * cupsdSetStringf() - Set a formatted string value.
26 * launchd_checkin() - Check-in with launchd and collect the listening
28 * launchd_checkout() - Update the launchd KeepAlive file as needed.
29 * parent_handler() - Catch USR1/CHLD signals...
30 * process_children() - Process all dead children...
31 * select_timeout() - Calculate the select timeout value.
32 * sigchld_handler() - Handle 'child' signals from old processes.
33 * sighup_handler() - Handle 'hangup' signals to reconfigure the
35 * sigterm_handler() - Handle 'terminate' signals that stop the scheduler.
36 * usage() - Show scheduler usage.
40 * Include necessary headers...
45 #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 */
78 static void launchd_checkin(void);
79 static void launchd_checkout(void);
80 #endif /* HAVE_LAUNCHD */
81 static void parent_handler(int sig
);
82 static void process_children(void);
83 static void sigchld_handler(int sig
);
84 static void sighup_handler(int sig
);
85 static void sigterm_handler(int sig
);
86 static long select_timeout(int fds
);
87 static void usage(int status
) __attribute__((noreturn
));
94 static int parent_signal
= 0;
95 /* Set to signal number from child */
96 static int holdcount
= 0; /* Number of times "hold" was called */
97 #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
98 static sigset_t holdmask
; /* Old POSIX signal mask */
99 #endif /* HAVE_SIGACTION && !HAVE_SIGSET */
100 static int dead_children
= 0;
102 static int stop_scheduler
= 0;
103 /* Should the scheduler stop? */
107 * 'main()' - Main entry for the CUPS scheduler.
110 int /* O - Exit status */
111 main(int argc
, /* I - Number of command-line args */
112 char *argv
[]) /* I - Command-line arguments */
114 int i
; /* Looping var */
115 char *opt
; /* Option character */
116 int fg
; /* Run in the foreground */
117 int fds
; /* Number of ready descriptors */
118 cupsd_client_t
*con
; /* Current client */
119 cupsd_job_t
*job
; /* Current job */
120 cupsd_listener_t
*lis
; /* Current listener */
121 time_t current_time
, /* Current time */
122 activity
, /* Client activity timer */
123 senddoc_time
, /* Send-Document time */
124 expire_time
, /* Subscription expire time */
125 report_time
, /* Malloc/client/job report time */
126 event_time
; /* Last event notification time */
127 long timeout
; /* Timeout for cupsdDoSelect() */
128 struct rlimit limit
; /* Runtime limit */
129 #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
130 struct sigaction action
; /* Actions for POSIX signals */
131 #endif /* HAVE_SIGACTION && !HAVE_SIGSET */
133 cups_file_t
*fp
; /* Fake lpsched lock file */
134 struct stat statbuf
; /* Needed for checking lpsched FIFO */
136 int run_as_child
= 0;
137 /* Needed for background fork/exec */
139 int use_sysman
= !getuid();
140 /* Use system management functions? */
142 time_t netif_time
= 0; /* Time since last network update */
143 #endif /* __APPLE__ */
145 int launchd_idle_exit
;
146 /* Idle exit on select timeout? */
147 #endif /* HAVE_LAUNCHD */
149 cupsd_timeout_t
*tmo
; /* Next scheduled timed callback */
150 long tmo_delay
; /* Time before it must be called */
151 #endif /* HAVE_AVAHI */
156 * Check for setuid invocation, which we do not support!
159 if (getuid() != geteuid())
161 fputs("cupsd: Cannot run as a setuid program\n", stderr
);
164 #endif /* HAVE_GETEUID */
167 * Check for command-line arguments...
173 if (getenv("CUPSD_LAUNCHD"))
178 #endif /* HAVE_LAUNCHD */
180 for (i
= 1; i
< argc
; i
++)
181 if (argv
[i
][0] == '-')
182 for (opt
= argv
[i
] + 1; *opt
!= '\0'; opt
++)
185 case 'C' : /* Run as child with config file */
189 case 'c' : /* Configuration file */
193 _cupsLangPuts(stderr
, _("cupsd: Expected config filename "
194 "after \"-c\" option."));
198 if (argv
[i
][0] == '/')
201 * Absolute directory...
204 cupsdSetString(&ConfigurationFile
, argv
[i
]);
209 * Relative directory...
212 char *current
; /* Current directory */
216 * Allocate a buffer for the current working directory to
217 * reduce run-time stack usage; this approximates the
218 * behavior of some implementations of getcwd() when they
219 * are passed a NULL pointer.
222 if ((current
= malloc(1024)) == NULL
)
224 _cupsLangPuts(stderr
,
225 _("cupsd: Unable to get current directory."));
229 if (!getcwd(current
, 1024))
231 _cupsLangPuts(stderr
,
232 _("cupsd: Unable to get current directory."));
237 cupsdSetStringf(&ConfigurationFile
, "%s/%s", current
, argv
[i
]);
242 case 'f' : /* Run in foreground... */
246 case 'F' : /* Run in foreground, but disconnect from terminal... */
250 case 'h' : /* Show usage/help */
254 case 'l' : /* Started by launchd... */
259 _cupsLangPuts(stderr
, _("cupsd: launchd(8) support not compiled "
260 "in, running in normal mode."));
262 #endif /* HAVE_LAUNCHD */
265 case 'p' : /* Stop immediately for profiling */
266 fputs("cupsd: -p (startup profiling) is for internal testing "
267 "use only!\n", stderr
);
272 case 'P' : /* Disable security profiles */
273 fputs("cupsd: -P (disable security profiles) is for internal "
274 "testing use only!\n", stderr
);
279 case 'S' : /* Disable system management functions */
280 fputs("cupsd: -S (disable system management) for internal "
281 "testing use only!\n", stderr
);
284 #endif /* __APPLE__ */
286 case 't' : /* Test the cupsd.conf file... */
291 default : /* Unknown option */
292 _cupsLangPrintf(stderr
, _("cupsd: Unknown option \"%c\" - "
299 _cupsLangPrintf(stderr
, _("cupsd: Unknown argument \"%s\" - aborting."),
304 if (!ConfigurationFile
)
305 cupsdSetString(&ConfigurationFile
, CUPS_SERVERROOT
"/cupsd.conf");
308 * If the user hasn't specified "-f", run in the background...
314 * Setup signal handlers for the parent...
317 #ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */
318 sigset(SIGUSR1
, parent_handler
);
319 sigset(SIGCHLD
, parent_handler
);
321 sigset(SIGHUP
, SIG_IGN
);
322 #elif defined(HAVE_SIGACTION)
323 memset(&action
, 0, sizeof(action
));
324 sigemptyset(&action
.sa_mask
);
325 sigaddset(&action
.sa_mask
, SIGUSR1
);
326 action
.sa_handler
= parent_handler
;
327 sigaction(SIGUSR1
, &action
, NULL
);
328 sigaction(SIGCHLD
, &action
, NULL
);
330 sigemptyset(&action
.sa_mask
);
331 action
.sa_handler
= SIG_IGN
;
332 sigaction(SIGHUP
, &action
, NULL
);
334 signal(SIGUSR1
, parent_handler
);
335 signal(SIGCLD
, parent_handler
);
337 signal(SIGHUP
, SIG_IGN
);
338 #endif /* HAVE_SIGSET */
343 * OK, wait for the child to startup and send us SIGUSR1 or to crash
344 * and the OS send us SIGCHLD... We also need to ignore SIGHUP which
345 * might be sent by the init script to restart the scheduler...
348 for (; parent_signal
== 0;)
351 if (parent_signal
== SIGUSR1
)
359 else if (WIFEXITED(i
))
361 fprintf(stderr
, "cupsd: Child exited with status %d\n",
367 fprintf(stderr
, "cupsd: Child exited on signal %d\n", WTERMSIG(i
));
374 * Call _thread_sys_closefrom() so the child process doesn't reset the
375 * parent's file descriptors to be blocking. This is a workaround for a
376 * limitation of userland libpthread on OpenBSD.
379 _thread_sys_closefrom(0);
380 #endif /* __OpenBSD__ */
383 * Since CoreFoundation and DBUS both create fork-unsafe data on execution of
384 * a program, and since this kind of really unfriendly behavior seems to be
385 * more common these days in system libraries, we need to re-execute the
386 * background cupsd with the "-C" option to avoid problems. Unfortunately,
387 * we also have to assume that argv[0] contains the name of the cupsd
388 * executable - there is no portable way to get the real pathname...
391 execlp(argv
[0], argv
[0], "-C", ConfigurationFile
, (char *)0);
398 * Make sure we aren't tying up any filesystems...
405 * Disable core dumps...
408 getrlimit(RLIMIT_CORE
, &limit
);
410 setrlimit(RLIMIT_CORE
, &limit
);
413 * Disconnect from the controlling terminal...
419 * Close all open files...
422 getrlimit(RLIMIT_NOFILE
, &limit
);
424 for (i
= 0; i
< limit
.rlim_cur
&& i
< 1024; i
++)
428 * Redirect stdin/out/err to /dev/null...
431 if ((i
= open("/dev/null", O_RDONLY
)) != 0)
437 if ((i
= open("/dev/null", O_WRONLY
)) != 1)
443 if ((i
= open("/dev/null", O_WRONLY
)) != 2)
452 * Set the timezone info...
458 setlocale(LC_TIME
, "");
462 * Set the maximum number of files...
465 getrlimit(RLIMIT_NOFILE
, &limit
);
467 #if !defined(HAVE_POLL) && !defined(HAVE_EPOLL) && !defined(HAVE_KQUEUE)
468 if (limit
.rlim_max
> FD_SETSIZE
)
471 #endif /* !HAVE_POLL && !HAVE_EPOLL && !HAVE_KQUEUE */
473 if (limit
.rlim_max
== RLIM_INFINITY
)
476 #endif /* RLIM_INFINITY */
477 MaxFDs
= limit
.rlim_max
;
479 limit
.rlim_cur
= MaxFDs
;
481 setrlimit(RLIMIT_NOFILE
, &limit
);
486 * Read configuration...
489 if (!cupsdReadConfiguration())
492 printf("%s contains errors\n", ConfigurationFile
);
494 syslog(LOG_LPR
, "Unable to read configuration file \'%s\' - exiting!",
498 else if (TestConfigFile
)
500 printf("%s is OK\n", ConfigurationFile
);
505 * Clean out old temp files and printer cache data.
508 if (!strncmp(TempDir
, RequestRoot
, strlen(RequestRoot
)))
509 cupsdCleanFiles(TempDir
, NULL
);
511 cupsdCleanFiles(CacheDir
, "*.ipp");
517 * If we were started by launchd get the listen sockets file descriptors...
523 #endif /* HAVE_LAUNCHD */
526 * Startup the server...
534 * Catch hangup and child signals and ignore broken pipes...
537 #ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */
538 sigset(SIGCHLD
, sigchld_handler
);
539 sigset(SIGHUP
, sighup_handler
);
540 sigset(SIGPIPE
, SIG_IGN
);
541 sigset(SIGTERM
, sigterm_handler
);
542 #elif defined(HAVE_SIGACTION)
543 memset(&action
, 0, sizeof(action
));
545 sigemptyset(&action
.sa_mask
);
546 sigaddset(&action
.sa_mask
, SIGTERM
);
547 sigaddset(&action
.sa_mask
, SIGCHLD
);
548 action
.sa_handler
= sigchld_handler
;
549 sigaction(SIGCHLD
, &action
, NULL
);
551 sigemptyset(&action
.sa_mask
);
552 sigaddset(&action
.sa_mask
, SIGHUP
);
553 action
.sa_handler
= sighup_handler
;
554 sigaction(SIGHUP
, &action
, NULL
);
556 sigemptyset(&action
.sa_mask
);
557 action
.sa_handler
= SIG_IGN
;
558 sigaction(SIGPIPE
, &action
, NULL
);
560 sigemptyset(&action
.sa_mask
);
561 sigaddset(&action
.sa_mask
, SIGTERM
);
562 sigaddset(&action
.sa_mask
, SIGCHLD
);
563 action
.sa_handler
= sigterm_handler
;
564 sigaction(SIGTERM
, &action
, NULL
);
566 signal(SIGCLD
, sigchld_handler
); /* No, SIGCLD isn't a typo... */
567 signal(SIGHUP
, sighup_handler
);
568 signal(SIGPIPE
, SIG_IGN
);
569 signal(SIGTERM
, sigterm_handler
);
570 #endif /* HAVE_SIGSET */
574 * Try to create a fake lpsched lock file if one is not already there.
575 * Some Adobe applications need it under IRIX in order to enable
579 if ((fp
= cupsFileOpen("/var/spool/lp/SCHEDLOCK", "w")) == NULL
)
581 syslog(LOG_LPR
, "Unable to create fake lpsched lock file "
582 "\"/var/spool/lp/SCHEDLOCK\"\' - %s!",
587 fchmod(cupsFileNumber(fp
), 0644);
588 fchown(cupsFileNumber(fp
), User
, Group
);
595 * Initialize authentication certificates...
601 * If we are running in the background, signal the parent process that
602 * we are up and running...
605 if (!fg
|| run_as_child
)
608 * Send a signal to the parent process, but only if the parent is
609 * not PID 1 (init). This avoids accidentally shutting down the
610 * system on OpenBSD if you CTRL-C the server before it is up...
613 i
= getppid(); /* Save parent PID to avoid race condition */
621 * Start power management framework...
625 cupsdStartSystemMonitor();
626 #endif /* __APPLE__ */
629 * Send server-started event...
634 cupsdAddEvent(CUPSD_EVENT_SERVER_STARTED
, NULL
, NULL
,
635 "Scheduler started via launchd.");
637 #endif /* HAVE_LAUNCHD */
639 cupsdAddEvent(CUPSD_EVENT_SERVER_STARTED
, NULL
, NULL
,
640 "Scheduler started in foreground.");
642 cupsdAddEvent(CUPSD_EVENT_SERVER_STARTED
, NULL
, NULL
,
643 "Scheduler started in background.");
646 * Start any pending print jobs...
655 current_time
= time(NULL
);
656 event_time
= current_time
;
657 expire_time
= current_time
;
660 senddoc_time
= current_time
;
662 while (!stop_scheduler
)
665 * Check if there are dead children to handle...
672 * Check if we need to load the server configuration file...
678 * Close any idle clients...
681 if (cupsArrayCount(Clients
) > 0)
683 for (con
= (cupsd_client_t
*)cupsArrayFirst(Clients
);
685 con
= (cupsd_client_t
*)cupsArrayNext(Clients
))
686 if (con
->http
.state
== HTTP_WAITING
)
687 cupsdCloseClient(con
);
689 con
->http
.keep_alive
= HTTP_KEEPALIVE_OFF
;
691 cupsdPauseListening();
695 * Restart if all clients are closed and all jobs finished, or
696 * if the reload timeout has elapsed...
699 if ((cupsArrayCount(Clients
) == 0 &&
700 (cupsArrayCount(PrintingJobs
) == 0 || NeedReload
!= RELOAD_ALL
)) ||
701 (time(NULL
) - ReloadTime
) >= ReloadTimeout
)
704 * Shutdown the server...
712 * Read configuration...
715 if (!cupsdReadConfiguration())
717 syslog(LOG_LPR
, "Unable to read configuration file \'%s\' - exiting!",
726 * If we were started by launchd, get the listen socket file
733 #endif /* HAVE_LAUNCHD */
736 * Startup the server...
744 * Send a server-restarted event...
747 cupsdAddEvent(CUPSD_EVENT_SERVER_RESTARTED
, NULL
, NULL
,
748 "Scheduler restarted.");
753 * Check for available input or ready output. If cupsdDoSelect()
754 * returns 0 or -1, something bad happened and we should exit
757 * Note that we at least have one listening socket open at all
761 if ((timeout
= select_timeout(fds
)) > 1 && LastEvent
)
766 * If no other work is scheduled and we're being controlled by
767 * launchd then timeout after 'LaunchdTimeout' seconds of
771 if (timeout
== 86400 && Launchd
&& LaunchdTimeout
&&
772 !cupsArrayCount(ActiveJobs
) &&
773 (!Browsing
|| !BrowseLocalProtocols
|| !cupsArrayCount(Printers
)))
775 timeout
= LaunchdTimeout
;
776 launchd_idle_exit
= 1;
779 launchd_idle_exit
= 0;
780 #endif /* HAVE_LAUNCHD */
782 if ((fds
= cupsdDoSelect(timeout
)) < 0)
785 * Got an error from select!
789 cupsd_printer_t
*p
; /* Current printer */
790 #endif /* HAVE_DNSSD */
793 if (errno
== EINTR
) /* Just interrupted by a signal */
797 * Log all sorts of debug info to help track down the problem.
800 cupsdLogMessage(CUPSD_LOG_EMERG
, "cupsdDoSelect() failed - %s!",
803 for (i
= 0, con
= (cupsd_client_t
*)cupsArrayFirst(Clients
);
805 i
++, con
= (cupsd_client_t
*)cupsArrayNext(Clients
))
806 cupsdLogMessage(CUPSD_LOG_EMERG
,
807 "Clients[%d] = %d, file = %d, state = %d",
808 i
, con
->http
.fd
, con
->file
, con
->http
.state
);
810 for (i
= 0, lis
= (cupsd_listener_t
*)cupsArrayFirst(Listeners
);
812 i
++, lis
= (cupsd_listener_t
*)cupsArrayNext(Listeners
))
813 cupsdLogMessage(CUPSD_LOG_EMERG
, "Listeners[%d] = %d", i
, lis
->fd
);
815 cupsdLogMessage(CUPSD_LOG_EMERG
, "CGIPipes[0] = %d", CGIPipes
[0]);
818 cupsdLogMessage(CUPSD_LOG_EMERG
, "SysEventPipes[0] = %d",
820 #endif /* __APPLE__ */
822 for (job
= (cupsd_job_t
*)cupsArrayFirst(ActiveJobs
);
824 job
= (cupsd_job_t
*)cupsArrayNext(ActiveJobs
))
825 cupsdLogMessage(CUPSD_LOG_EMERG
, "Jobs[%d] = %d < [%d %d] > [%d %d]",
827 job
->status_buffer
? job
->status_buffer
->fd
: -1,
828 job
->print_pipes
[0], job
->print_pipes
[1],
829 job
->back_pipes
[0], job
->back_pipes
[1]);
832 for (p
= (cupsd_printer_t
*)cupsArrayFirst(Printers
);
834 p
= (cupsd_printer_t
*)cupsArrayNext(Printers
))
835 cupsdLogMessage(CUPSD_LOG_EMERG
, "printer[%s] reg_name=\"%s\"", p
->name
,
836 p
->reg_name
? p
->reg_name
: "(null)");
837 #endif /* HAVE_DNSSD */
842 current_time
= time(NULL
);
845 * Write dirty config/state files...
848 if (DirtyCleanTime
&& current_time
>= DirtyCleanTime
)
853 * If we are going to sleep and still have pending jobs, stop them after
854 * a period of time...
857 if (SleepJobs
> 0 && current_time
>= SleepJobs
&&
858 cupsArrayCount(PrintingJobs
) > 0)
861 cupsdStopAllJobs(CUPSD_JOB_DEFAULT
, 5);
863 #endif /* __APPLE__ */
867 * If a timed callback is due, run it.
870 tmo
= cupsdNextTimeout(&tmo_delay
);
871 if (tmo
&& tmo_delay
== 0)
872 cupsdRunTimeout(tmo
);
873 #endif /* HAVE_AVAHI */
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
;
925 #ifndef HAVE_AUTHORIZATION_H
927 * Update the root certificate once every 5 minutes if we have client
931 if ((current_time
- RootCertTime
) >= RootCertDuration
&& RootCertDuration
&&
932 !RunUser
&& cupsArrayCount(Clients
))
935 * Update the root certificate...
939 cupsdAddCert(0, "root", NULL
);
941 #endif /* !HAVE_AUTHORIZATION_H */
944 * Check for new data on the client sockets...
947 for (con
= (cupsd_client_t
*)cupsArrayFirst(Clients
);
949 con
= (cupsd_client_t
*)cupsArrayNext(Clients
))
952 * Process pending data in the input buffer...
957 cupsdReadClient(con
);
962 * Check the activity and close old clients...
965 activity
= current_time
- Timeout
;
966 if (con
->http
.activity
< activity
&& !con
->pipe_pid
)
968 cupsdLogMessage(CUPSD_LOG_DEBUG
,
969 "Closing client %d after %d seconds of inactivity...",
970 con
->http
.fd
, Timeout
);
972 cupsdCloseClient(con
);
978 * Update any pending multi-file documents...
981 if ((current_time
- senddoc_time
) >= 10)
985 senddoc_time
= current_time
;
989 * Log statistics at most once a minute when in debug mode...
992 if ((current_time
- report_time
) >= 60 && LogLevel
>= CUPSD_LOG_DEBUG
)
994 size_t string_count
, /* String count */
995 alloc_bytes
, /* Allocated string bytes */
996 total_bytes
; /* Total string bytes */
998 struct mallinfo mem
; /* Malloc information */
1002 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Report: malloc-arena=%lu", mem
.arena
);
1003 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Report: malloc-used=%lu",
1004 mem
.usmblks
+ mem
.uordblks
);
1005 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Report: malloc-free=%lu",
1006 mem
.fsmblks
+ mem
.fordblks
);
1007 #endif /* HAVE_MALLINFO */
1009 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Report: clients=%d",
1010 cupsArrayCount(Clients
));
1011 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Report: jobs=%d",
1012 cupsArrayCount(Jobs
));
1013 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Report: jobs-active=%d",
1014 cupsArrayCount(ActiveJobs
));
1015 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Report: printers=%d",
1016 cupsArrayCount(Printers
));
1018 string_count
= _cupsStrStatistics(&alloc_bytes
, &total_bytes
);
1019 cupsdLogMessage(CUPSD_LOG_DEBUG
,
1020 "Report: stringpool-string-count=" CUPS_LLFMT
,
1021 CUPS_LLCAST string_count
);
1022 cupsdLogMessage(CUPSD_LOG_DEBUG
,
1023 "Report: stringpool-alloc-bytes=" CUPS_LLFMT
,
1024 CUPS_LLCAST alloc_bytes
);
1025 cupsdLogMessage(CUPSD_LOG_DEBUG
,
1026 "Report: stringpool-total-bytes=" CUPS_LLFMT
,
1027 CUPS_LLCAST total_bytes
);
1029 report_time
= current_time
;
1033 * Handle OS-specific event notification for any events that have
1034 * accumulated. Don't send these more than once a second...
1037 if (LastEvent
&& (current_time
- event_time
) >= 1)
1039 #ifdef HAVE_NOTIFY_POST
1040 if (LastEvent
& (CUPSD_EVENT_PRINTER_ADDED
|
1041 CUPSD_EVENT_PRINTER_DELETED
|
1042 CUPSD_EVENT_PRINTER_MODIFIED
))
1044 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1045 "notify_post(\"com.apple.printerListChange\")");
1046 notify_post("com.apple.printerListChange");
1049 if (LastEvent
& CUPSD_EVENT_PRINTER_STATE_CHANGED
)
1051 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1052 "notify_post(\"com.apple.printerHistoryChange\")");
1053 notify_post("com.apple.printerHistoryChange");
1056 if (LastEvent
& (CUPSD_EVENT_JOB_STATE_CHANGED
|
1057 CUPSD_EVENT_JOB_CONFIG_CHANGED
|
1058 CUPSD_EVENT_JOB_PROGRESS
))
1060 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1061 "notify_post(\"com.apple.jobChange\")");
1062 notify_post("com.apple.jobChange");
1064 #endif /* HAVE_NOTIFY_POST */
1067 * Reset the accumulated events...
1070 LastEvent
= CUPSD_EVENT_NONE
;
1071 event_time
= current_time
;
1076 * Log a message based on what happened...
1081 cupsdLogMessage(CUPSD_LOG_INFO
, "Scheduler shutting down normally.");
1082 cupsdAddEvent(CUPSD_EVENT_SERVER_STOPPED
, NULL
, NULL
,
1083 "Scheduler shutting down normally.");
1087 cupsdLogMessage(CUPSD_LOG_ERROR
,
1088 "Scheduler shutting down due to program error.");
1089 cupsdAddEvent(CUPSD_EVENT_SERVER_STOPPED
, NULL
, NULL
,
1090 "Scheduler shutting down due to program error.");
1094 * Close all network clients...
1103 * Update the launchd KeepAlive file as needed...
1108 #endif /* HAVE_LAUNCHD */
1118 * Stop monitoring system event monitoring...
1122 cupsdStopSystemMonitor();
1123 #endif /* __APPLE__ */
1127 * Free the scheduler's Kerberos context...
1132 * If the weak-linked GSSAPI/Kerberos library is not present, don't try
1136 if (krb5_init_context
!= NULL
)
1137 # endif /* __APPLE__ */
1138 if (KerberosContext
)
1139 krb5_free_context(KerberosContext
);
1140 #endif /* HAVE_GSSAPI */
1144 * Remove the fake IRIX lpsched lock file, but only if the existing
1145 * file is not a FIFO which indicates that the real IRIX lpsched is
1149 if (!stat("/var/spool/lp/FIFO", &statbuf
))
1150 if (!S_ISFIFO(statbuf
.st_mode
))
1151 unlink("/var/spool/lp/SCHEDLOCK");
1156 return (!stop_scheduler
);
1161 * 'cupsdAddString()' - Copy and add a string to an array.
1164 int /* O - 1 on success, 0 on failure */
1165 cupsdAddString(cups_array_t
**a
, /* IO - String array */
1166 const char *s
) /* I - String to copy and add */
1169 *a
= cupsArrayNew3((cups_array_func_t
)strcmp
, NULL
,
1170 (cups_ahash_func_t
)NULL
, 0,
1171 (cups_acopy_func_t
)_cupsStrAlloc
,
1172 (cups_afree_func_t
)_cupsStrFree
);
1174 return (cupsArrayAdd(*a
, (char *)s
));
1179 * 'cupsdCheckProcess()' - Tell the main loop to check for dead children.
1183 cupsdCheckProcess(void)
1186 * Flag that we have dead children...
1194 * 'cupsdClearString()' - Clear a string.
1198 cupsdClearString(char **s
) /* O - String value */
1209 * 'cupsdFreeStrings()' - Free an array of strings.
1213 cupsdFreeStrings(cups_array_t
**a
) /* IO - String array */
1217 cupsArrayDelete(*a
);
1224 * 'cupsdHoldSignals()' - Hold child and termination signals.
1228 cupsdHoldSignals(void)
1230 #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
1231 sigset_t newmask
; /* New POSIX signal mask */
1232 #endif /* HAVE_SIGACTION && !HAVE_SIGSET */
1242 #elif defined(HAVE_SIGACTION)
1243 sigemptyset(&newmask
);
1244 sigaddset(&newmask
, SIGTERM
);
1245 sigaddset(&newmask
, SIGCHLD
);
1246 sigprocmask(SIG_BLOCK
, &newmask
, &holdmask
);
1247 #endif /* HAVE_SIGSET */
1252 * 'cupsdReleaseSignals()' - Release signals for delivery.
1256 cupsdReleaseSignals(void)
1265 #elif defined(HAVE_SIGACTION)
1266 sigprocmask(SIG_SETMASK
, &holdmask
, NULL
);
1267 #endif /* HAVE_SIGSET */
1272 * 'cupsdSetString()' - Set a string value.
1276 cupsdSetString(char **s
, /* O - New string */
1277 const char *v
) /* I - String value */
1286 *s
= _cupsStrAlloc(v
);
1293 * 'cupsdSetStringf()' - Set a formatted string value.
1297 cupsdSetStringf(char **s
, /* O - New string */
1298 const char *f
, /* I - Printf-style format string */
1299 ...) /* I - Additional args as needed */
1301 char v
[4096]; /* Formatting string value */
1302 va_list ap
; /* Argument pointer */
1303 char *olds
; /* Old string */
1314 vsnprintf(v
, sizeof(v
), f
, ap
);
1317 *s
= _cupsStrAlloc(v
);
1329 * 'launchd_checkin()' - Check-in with launchd and collect the listening fds.
1333 launchd_checkin(void)
1335 size_t i
, /* Looping var */
1336 count
; /* Number of listeners */
1337 launch_data_t ld_msg
, /* Launch data message */
1338 ld_resp
, /* Launch data response */
1339 ld_array
, /* Launch data array */
1340 ld_sockets
, /* Launch data sockets dictionary */
1341 tmp
; /* Launch data */
1342 cupsd_listener_t
*lis
; /* Listeners array */
1343 http_addr_t addr
; /* Address variable */
1344 socklen_t addrlen
; /* Length of address */
1345 int fd
; /* File descriptor */
1346 char s
[256]; /* String addresss */
1349 cupsdLogMessage(CUPSD_LOG_DEBUG
, "launchd_checkin: pid=%d", (int)getpid());
1352 * Check-in with launchd...
1355 ld_msg
= launch_data_new_string(LAUNCH_KEY_CHECKIN
);
1356 if ((ld_resp
= launch_msg(ld_msg
)) == NULL
)
1358 cupsdLogMessage(CUPSD_LOG_ERROR
,
1359 "launchd_checkin: launch_msg(\"" LAUNCH_KEY_CHECKIN
1362 return; /* anti-compiler-warning */
1365 if (launch_data_get_type(ld_resp
) == LAUNCH_DATA_ERRNO
)
1367 errno
= launch_data_get_errno(ld_resp
);
1368 cupsdLogMessage(CUPSD_LOG_ERROR
, "launchd_checkin: Check-in failed: %s",
1371 return; /* anti-compiler-warning */
1375 * Get the sockets dictionary...
1378 if ((ld_sockets
= launch_data_dict_lookup(ld_resp
, LAUNCH_JOBKEY_SOCKETS
))
1381 cupsdLogMessage(CUPSD_LOG_ERROR
,
1382 "launchd_checkin: No sockets found to answer requests on!");
1384 return; /* anti-compiler-warning */
1388 * Get the array of listener sockets...
1391 if ((ld_array
= launch_data_dict_lookup(ld_sockets
, "Listeners")) == NULL
)
1393 cupsdLogMessage(CUPSD_LOG_ERROR
,
1394 "launchd_checkin: No sockets found to answer requests on!");
1396 return; /* anti-compiler-warning */
1400 * Add listening fd(s) to the Listener array...
1403 if (launch_data_get_type(ld_array
) == LAUNCH_DATA_ARRAY
)
1405 count
= launch_data_array_get_count(ld_array
);
1407 for (i
= 0; i
< count
; i
++)
1410 * Get the launchd file descriptor and address...
1413 if ((tmp
= launch_data_array_get_index(ld_array
, i
)) != NULL
)
1415 fd
= launch_data_get_fd(tmp
);
1416 addrlen
= sizeof(addr
);
1418 if (getsockname(fd
, (struct sockaddr
*)&addr
, &addrlen
))
1420 cupsdLogMessage(CUPSD_LOG_ERROR
,
1421 "launchd_checkin: Unable to get local address - %s",
1427 * Try to match the launchd socket address to one of the listeners...
1430 for (lis
= (cupsd_listener_t
*)cupsArrayFirst(Listeners
);
1432 lis
= (cupsd_listener_t
*)cupsArrayNext(Listeners
))
1433 if (httpAddrEqual(&lis
->address
, &addr
))
1437 * Add a new listener If there's no match...
1442 cupsdLogMessage(CUPSD_LOG_DEBUG
,
1443 "launchd_checkin: Matched existing listener %s with fd %d...",
1444 httpAddrString(&(lis
->address
), s
, sizeof(s
)), fd
);
1448 cupsdLogMessage(CUPSD_LOG_DEBUG
,
1449 "launchd_checkin: Adding new listener %s with fd %d...",
1450 httpAddrString(&addr
, s
, sizeof(s
)), fd
);
1452 if ((lis
= calloc(1, sizeof(cupsd_listener_t
))) == NULL
)
1454 cupsdLogMessage(CUPSD_LOG_ERROR
,
1455 "launchd_checkin: Unable to allocate listener - "
1456 "%s.", strerror(errno
));
1460 cupsArrayAdd(Listeners
, lis
);
1462 memcpy(&lis
->address
, &addr
, sizeof(lis
->address
));
1468 if (_httpAddrPort(&(lis
->address
)) == 443)
1469 lis
->encryption
= HTTP_ENCRYPT_ALWAYS
;
1470 # endif /* HAVE_SSL */
1475 launch_data_free(ld_msg
);
1476 launch_data_free(ld_resp
);
1481 * 'launchd_checkout()' - Update the launchd KeepAlive file as needed.
1485 launchd_checkout(void)
1487 int fd
; /* File descriptor */
1491 * Create or remove the launchd KeepAlive file based on whether
1492 * there are active jobs, polling, browsing for remote printers or
1493 * shared printers to advertise...
1496 if (cupsArrayCount(ActiveJobs
) ||
1497 (Browsing
&& BrowseLocalProtocols
&& cupsArrayCount(Printers
)))
1499 cupsdLogMessage(CUPSD_LOG_DEBUG
,
1500 "Creating launchd keepalive file \"" CUPS_KEEPALIVE
1503 if ((fd
= open(CUPS_KEEPALIVE
, O_RDONLY
| O_CREAT
| O_EXCL
, S_IRUSR
)) >= 0)
1508 cupsdLogMessage(CUPSD_LOG_DEBUG
,
1509 "Removing launchd keepalive file \"" CUPS_KEEPALIVE
1512 unlink(CUPS_KEEPALIVE
);
1515 #endif /* HAVE_LAUNCHD */
1519 * 'parent_handler()' - Catch USR1/CHLD signals...
1523 parent_handler(int sig
) /* I - Signal */
1526 * Store the signal we got from the OS and return...
1529 parent_signal
= sig
;
1534 * 'process_children()' - Process all dead children...
1538 process_children(void)
1540 int status
; /* Exit status of child */
1541 int pid
, /* Process ID of child */
1542 job_id
; /* Job ID of child */
1543 cupsd_job_t
*job
; /* Current job */
1544 int i
; /* Looping var */
1545 char name
[1024]; /* Process name */
1546 const char *type
; /* Type of program */
1549 cupsdLogMessage(CUPSD_LOG_DEBUG2
, "process_children()");
1552 * Reset the dead_children flag...
1558 * Collect the exit status of some children...
1562 while ((pid
= waitpid(-1, &status
, WNOHANG
)) > 0)
1563 #elif defined(HAVE_WAIT3)
1564 while ((pid
= wait3(&status
, WNOHANG
, NULL
)) > 0)
1566 if ((pid
= wait(&status
)) > 0)
1567 #endif /* HAVE_WAITPID */
1570 * Collect the name of the process that finished...
1573 cupsdFinishProcess(pid
, name
, sizeof(name
), &job_id
);
1576 * Delete certificates for CGI processes...
1580 cupsdDeleteCert(pid
);
1583 * Handle completed job filters...
1587 job
= cupsdFindJob(job_id
);
1593 for (i
= 0; job
->filters
[i
]; i
++)
1594 if (job
->filters
[i
] == pid
)
1597 if (job
->filters
[i
] || job
->backend
== pid
)
1600 * OK, this process has gone away; what's left?
1603 if (job
->filters
[i
])
1605 job
->filters
[i
] = -pid
;
1610 job
->backend
= -pid
;
1614 if (status
&& status
!= SIGTERM
&& status
!= SIGKILL
&&
1615 status
!= SIGPIPE
&& job
->status
>= 0)
1618 * An error occurred; save the exit status so we know to stop
1619 * the printer or cancel the job when all of the filters finish...
1621 * A negative status indicates that the backend failed and the
1622 * printer needs to be stopped.
1625 if (job
->filters
[i
])
1626 job
->status
= status
; /* Filter failed */
1628 job
->status
= -status
; /* Backend failed */
1630 if (job
->state_value
== IPP_JOB_PROCESSING
&&
1631 job
->status_level
> CUPSD_LOG_ERROR
&&
1632 (job
->filters
[i
] || !WIFEXITED(status
)))
1634 char message
[1024]; /* New printer-state-message */
1637 job
->status_level
= CUPSD_LOG_ERROR
;
1639 snprintf(message
, sizeof(message
), "%s failed", type
);
1643 strlcpy(job
->printer
->state_message
, message
,
1644 sizeof(job
->printer
->state_message
));
1650 if (!job
->printer_message
&& job
->attrs
)
1652 if ((job
->printer_message
=
1653 ippFindAttribute(job
->attrs
, "job-printer-state-message",
1654 IPP_TAG_TEXT
)) == NULL
)
1655 job
->printer_message
= ippAddString(job
->attrs
, IPP_TAG_JOB
,
1657 "job-printer-state-message",
1661 if (job
->printer_message
)
1662 cupsdSetString(&(job
->printer_message
->values
[0].string
.text
),
1668 * If this is not the last file in a job, see if all of the
1669 * filters are done, and if so move to the next file.
1672 if (job
->current_file
< job
->num_files
&& job
->printer
)
1674 for (i
= 0; job
->filters
[i
] < 0; i
++);
1676 if (!job
->filters
[i
] &&
1677 (!job
->printer
->pc
|| !job
->printer
->pc
->single_file
||
1681 * Process the next file...
1684 cupsdContinueJob(job
);
1687 else if (job
->state_value
>= IPP_JOB_CANCELED
)
1690 * Remove the job from the active list if there are no processes still
1694 for (i
= 0; job
->filters
[i
] < 0; i
++);
1696 if (!job
->filters
[i
] && job
->backend
<= 0)
1697 cupsArrayRemove(ActiveJobs
, job
);
1703 * Show the exit status as needed, ignoring SIGTERM and SIGKILL errors
1704 * since they come when we kill/end a process...
1707 if (status
== SIGTERM
|| status
== SIGKILL
)
1709 cupsdLogJob(job
, CUPSD_LOG_DEBUG
,
1710 "PID %d (%s) was terminated normally with signal %d.", pid
,
1713 else if (status
== SIGPIPE
)
1715 cupsdLogJob(job
, CUPSD_LOG_DEBUG
,
1716 "PID %d (%s) did not catch or ignore signal %d.", pid
, name
,
1721 if (WIFEXITED(status
))
1723 int code
= WEXITSTATUS(status
); /* Exit code */
1726 cupsdLogJob(job
, CUPSD_LOG_DEBUG
,
1727 "PID %d (%s) stopped with status %d (%s)", pid
, name
,
1728 code
, strerror(code
- 100));
1730 cupsdLogJob(job
, CUPSD_LOG_DEBUG
,
1731 "PID %d (%s) stopped with status %d.", pid
, name
, code
);
1734 cupsdLogJob(job
, CUPSD_LOG_DEBUG
, "PID %d (%s) crashed on signal %d.",
1735 pid
, name
, WTERMSIG(status
));
1737 if (LogLevel
< CUPSD_LOG_DEBUG
)
1738 cupsdLogJob(job
, CUPSD_LOG_INFO
,
1739 "Hint: Try setting the LogLevel to \"debug\" to find out "
1743 cupsdLogJob(job
, CUPSD_LOG_DEBUG
, "PID %d (%s) exited with no errors.",
1748 * If wait*() is interrupted by a signal, tell main() to call us again...
1751 if (pid
< 0 && errno
== EINTR
)
1757 * 'select_timeout()' - Calculate the select timeout value.
1761 static long /* O - Number of seconds */
1762 select_timeout(int fds
) /* I - Number of descriptors returned */
1764 long timeout
; /* Timeout for select */
1765 time_t now
; /* Current time */
1766 cupsd_client_t
*con
; /* Client information */
1767 cupsd_job_t
*job
; /* Job information */
1768 cupsd_subscription_t
*sub
; /* Subscription information */
1769 const char *why
; /* Debugging aid */
1771 cupsd_timeout_t
*tmo
; /* Timed callback */
1772 long tmo_delay
; /* Seconds before calling it */
1773 #endif /* HAVE_AVAHI */
1777 * Check to see if any of the clients have pending data to be
1778 * processed; if so, the timeout should be 0...
1781 for (con
= (cupsd_client_t
*)cupsArrayFirst(Clients
);
1783 con
= (cupsd_client_t
*)cupsArrayNext(Clients
))
1784 if (con
->http
.used
> 0)
1788 * If select has been active in the last second (fds > 0) or we have
1789 * many resources in use then don't bother trying to optimize the
1790 * timeout, just make it 1 second.
1793 if (fds
> 0 || cupsArrayCount(Clients
) > 50)
1797 * Otherwise, check all of the possible events that we need to wake for...
1801 timeout
= now
+ 86400; /* 86400 == 1 day */
1806 * When going to sleep, wake up to cancel jobs that don't complete in time.
1809 if (SleepJobs
> 0 && SleepJobs
< timeout
)
1811 timeout
= SleepJobs
;
1812 why
= "cancel jobs before sleeping";
1814 #endif /* __APPLE__ */
1818 * See if there are any scheduled timed callbacks to run.
1821 if ((tmo
= cupsdNextTimeout(&tmo_delay
)) != NULL
&&
1822 (now
+ tmo_delay
) < timeout
)
1824 timeout
= tmo_delay
;
1825 why
= "run a timed callback";
1827 #endif /* HAVE_AVAHI */
1830 * Check whether we are accepting new connections...
1833 if (ListeningPaused
> 0 && cupsArrayCount(Clients
) < MaxClients
&&
1834 ListeningPaused
< timeout
)
1836 if (ListeningPaused
<= now
)
1839 timeout
= ListeningPaused
;
1841 why
= "resume listening";
1845 * Check the activity and close old clients...
1848 for (con
= (cupsd_client_t
*)cupsArrayFirst(Clients
);
1850 con
= (cupsd_client_t
*)cupsArrayNext(Clients
))
1851 if ((con
->http
.activity
+ Timeout
) < timeout
)
1853 timeout
= con
->http
.activity
+ Timeout
;
1854 why
= "timeout a client connection";
1858 * Write out changes to configuration and state files...
1861 if (DirtyCleanTime
&& timeout
> DirtyCleanTime
)
1863 timeout
= DirtyCleanTime
;
1864 why
= "write dirty config/state files";
1868 * Check for any active jobs...
1871 for (job
= (cupsd_job_t
*)cupsArrayFirst(ActiveJobs
);
1873 job
= (cupsd_job_t
*)cupsArrayNext(ActiveJobs
))
1875 if (job
->kill_time
&& job
->kill_time
< timeout
)
1877 timeout
= job
->kill_time
;
1878 why
= "kill unresponsive jobs";
1880 else if (job
->cancel_time
&& job
->cancel_time
< timeout
)
1882 timeout
= job
->cancel_time
;
1883 why
= "cancel stuck jobs";
1885 else if (job
->state_value
== IPP_JOB_HELD
&& job
->hold_until
< timeout
)
1887 timeout
= job
->hold_until
;
1888 why
= "release held jobs";
1890 else if (job
->state_value
== IPP_JOB_PENDING
&& timeout
> (now
+ 10))
1893 why
= "start pending jobs";
1898 #ifdef HAVE_MALLINFO
1900 * Log memory usage every minute...
1903 if (LogLevel
>= CUPSD_LOG_DEBUG
&& (mallinfo_time
+ 60) < timeout
)
1905 timeout
= mallinfo_time
+ 60;
1906 why
= "display memory usage";
1908 #endif /* HAVE_MALLINFO */
1911 * Expire subscriptions as needed...
1914 for (sub
= (cupsd_subscription_t
*)cupsArrayFirst(Subscriptions
);
1916 sub
= (cupsd_subscription_t
*)cupsArrayNext(Subscriptions
))
1917 if (!sub
->job
&& sub
->expire
&& sub
->expire
< timeout
)
1919 timeout
= sub
->expire
;
1920 why
= "expire subscription";
1924 * Adjust from absolute to relative time. We add 1 second to the timeout since
1925 * events occur after the timeout expires, and limit the timeout to 86400
1926 * seconds (1 day) to avoid select() timeout limits present on some operating
1930 timeout
= timeout
- now
+ 1;
1934 else if (timeout
> 86400)
1938 * Log and return the timeout value...
1941 cupsdLogMessage(CUPSD_LOG_DEBUG2
, "select_timeout(%d): %ld seconds to %s",
1949 * 'sigchld_handler()' - Handle 'child' signals from old processes.
1953 sigchld_handler(int sig
) /* I - Signal number */
1958 * Flag that we have dead children...
1964 * Reset the signal handler as needed...
1967 #if !defined(HAVE_SIGSET) && !defined(HAVE_SIGACTION)
1968 signal(SIGCLD
, sigchld_handler
);
1969 #endif /* !HAVE_SIGSET && !HAVE_SIGACTION */
1974 * 'sighup_handler()' - Handle 'hangup' signals to reconfigure the scheduler.
1978 sighup_handler(int sig
) /* I - Signal number */
1982 NeedReload
= RELOAD_ALL
;
1983 ReloadTime
= time(NULL
);
1985 #if !defined(HAVE_SIGSET) && !defined(HAVE_SIGACTION)
1986 signal(SIGHUP
, sighup_handler
);
1987 #endif /* !HAVE_SIGSET && !HAVE_SIGACTION */
1992 * 'sigterm_handler()' - Handle 'terminate' signals that stop the scheduler.
1996 sigterm_handler(int sig
) /* I - Signal number */
1998 (void)sig
; /* remove compiler warnings... */
2001 * Flag that we should stop and return...
2009 * 'usage()' - Show scheduler usage.
2013 usage(int status
) /* O - Exit status */
2015 FILE *fp
= status
? stderr
: stdout
; /* Output file */
2018 _cupsLangPuts(fp
, _("Usage: cupsd [options]"));
2019 _cupsLangPuts(fp
, _("Options:"));
2020 _cupsLangPuts(fp
, _(" -c config-file Load alternate configuration "
2022 _cupsLangPuts(fp
, _(" -f Run in the foreground."));
2023 _cupsLangPuts(fp
, _(" -F Run in the foreground but "
2024 "detach from console."));
2025 _cupsLangPuts(fp
, _(" -h Show this usage message."));
2026 _cupsLangPuts(fp
, _(" -l Run cupsd from launchd(8)."));
2027 _cupsLangPuts(fp
, _(" -t Test the configuration "
2035 * End of "$Id: main.c 7925 2008-09-10 17:47:26Z mike $".