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 */
71 #endif /* HAVE_NOTIFY_H */
73 #ifdef HAVE_SYS_PARAM_H
74 # include <sys/param.h>
75 #endif /* HAVE_SYS_PARAM_H */
83 static void launchd_checkin(void);
84 static void launchd_checkout(void);
85 #endif /* HAVE_LAUNCHD */
86 static void parent_handler(int sig
);
87 static void process_children(void);
88 static void sigchld_handler(int sig
);
89 static void sighup_handler(int sig
);
90 static void sigterm_handler(int sig
);
91 static long select_timeout(int fds
);
92 static void usage(int status
) __attribute__((noreturn
));
99 static int parent_signal
= 0;
100 /* Set to signal number from child */
101 static int holdcount
= 0; /* Number of times "hold" was called */
102 #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
103 static sigset_t holdmask
; /* Old POSIX signal mask */
104 #endif /* HAVE_SIGACTION && !HAVE_SIGSET */
105 static int dead_children
= 0;
107 static int stop_scheduler
= 0;
108 /* Should the scheduler stop? */
112 * 'main()' - Main entry for the CUPS scheduler.
115 int /* O - Exit status */
116 main(int argc
, /* I - Number of command-line args */
117 char *argv
[]) /* I - Command-line arguments */
119 int i
; /* Looping var */
120 char *opt
; /* Option character */
121 int fg
; /* Run in the foreground */
122 int fds
; /* Number of ready descriptors */
123 cupsd_client_t
*con
; /* Current client */
124 cupsd_job_t
*job
; /* Current job */
125 cupsd_listener_t
*lis
; /* Current listener */
126 time_t current_time
, /* Current time */
127 activity
, /* Client activity timer */
128 senddoc_time
, /* Send-Document time */
129 expire_time
, /* Subscription expire time */
130 report_time
, /* Malloc/client/job report time */
131 event_time
; /* Last event notification time */
132 long timeout
; /* Timeout for cupsdDoSelect() */
133 struct rlimit limit
; /* Runtime limit */
134 #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
135 struct sigaction action
; /* Actions for POSIX signals */
136 #endif /* HAVE_SIGACTION && !HAVE_SIGSET */
137 int run_as_child
= 0;
138 /* Needed for background fork/exec */
140 int use_sysman
= !getuid();
141 /* Use system management functions? */
143 time_t netif_time
= 0; /* Time since last network update */
144 #endif /* __APPLE__ */
146 int launchd_idle_exit
;
147 /* Idle exit on select timeout? */
148 #endif /* HAVE_LAUNCHD */
153 * Check for setuid invocation, which we do not support!
156 if (getuid() != geteuid())
158 fputs("cupsd: Cannot run as a setuid program\n", stderr
);
161 #endif /* HAVE_GETEUID */
164 * Check for command-line arguments...
170 if (getenv("CUPSD_LAUNCHD"))
175 #endif /* HAVE_LAUNCHD */
177 for (i
= 1; i
< argc
; i
++)
178 if (argv
[i
][0] == '-')
179 for (opt
= argv
[i
] + 1; *opt
!= '\0'; opt
++)
182 case 'C' : /* Run as child with config file */
186 case 'c' : /* Configuration file */
190 _cupsLangPuts(stderr
, _("cupsd: Expected config filename "
191 "after \"-c\" option."));
195 if (argv
[i
][0] == '/')
198 * Absolute directory...
201 cupsdSetString(&ConfigurationFile
, argv
[i
]);
206 * Relative directory...
209 char *current
; /* Current directory */
213 * Allocate a buffer for the current working directory to
214 * reduce run-time stack usage; this approximates the
215 * behavior of some implementations of getcwd() when they
216 * are passed a NULL pointer.
219 if ((current
= malloc(1024)) == NULL
)
221 _cupsLangPuts(stderr
,
222 _("cupsd: Unable to get current directory."));
226 if (!getcwd(current
, 1024))
228 _cupsLangPuts(stderr
,
229 _("cupsd: Unable to get current directory."));
234 cupsdSetStringf(&ConfigurationFile
, "%s/%s", current
, argv
[i
]);
239 case 'f' : /* Run in foreground... */
243 case 'F' : /* Run in foreground, but disconnect from terminal... */
247 case 'h' : /* Show usage/help */
251 case 'l' : /* Started by launchd... */
256 _cupsLangPuts(stderr
, _("cupsd: launchd(8) support not compiled "
257 "in, running in normal mode."));
259 #endif /* HAVE_LAUNCHD */
262 case 'p' : /* Stop immediately for profiling */
263 fputs("cupsd: -p (startup profiling) is for internal testing "
264 "use only!\n", stderr
);
269 case 'P' : /* Disable security profiles */
270 fputs("cupsd: -P (disable security profiles) is for internal "
271 "testing use only!\n", stderr
);
276 case 'S' : /* Disable system management functions */
277 fputs("cupsd: -S (disable system management) for internal "
278 "testing use only!\n", stderr
);
281 #endif /* __APPLE__ */
283 case 't' : /* Test the cupsd.conf file... */
288 default : /* Unknown option */
289 _cupsLangPrintf(stderr
, _("cupsd: Unknown option \"%c\" - "
296 _cupsLangPrintf(stderr
, _("cupsd: Unknown argument \"%s\" - aborting."),
301 if (!ConfigurationFile
)
302 cupsdSetString(&ConfigurationFile
, CUPS_SERVERROOT
"/cupsd.conf");
305 * If the user hasn't specified "-f", run in the background...
311 * Setup signal handlers for the parent...
314 #ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */
315 sigset(SIGUSR1
, parent_handler
);
316 sigset(SIGCHLD
, parent_handler
);
318 sigset(SIGHUP
, SIG_IGN
);
319 #elif defined(HAVE_SIGACTION)
320 memset(&action
, 0, sizeof(action
));
321 sigemptyset(&action
.sa_mask
);
322 sigaddset(&action
.sa_mask
, SIGUSR1
);
323 action
.sa_handler
= parent_handler
;
324 sigaction(SIGUSR1
, &action
, NULL
);
325 sigaction(SIGCHLD
, &action
, NULL
);
327 sigemptyset(&action
.sa_mask
);
328 action
.sa_handler
= SIG_IGN
;
329 sigaction(SIGHUP
, &action
, NULL
);
331 signal(SIGUSR1
, parent_handler
);
332 signal(SIGCLD
, parent_handler
);
334 signal(SIGHUP
, SIG_IGN
);
335 #endif /* HAVE_SIGSET */
340 * OK, wait for the child to startup and send us SIGUSR1 or to crash
341 * and the OS send us SIGCHLD... We also need to ignore SIGHUP which
342 * might be sent by the init script to restart the scheduler...
345 for (; parent_signal
== 0;)
348 if (parent_signal
== SIGUSR1
)
356 else if (WIFEXITED(i
))
358 fprintf(stderr
, "cupsd: Child exited with status %d\n",
364 fprintf(stderr
, "cupsd: Child exited on signal %d\n", WTERMSIG(i
));
369 #if defined(__OpenBSD__) && OpenBSD < 201211
371 * Call _thread_sys_closefrom() so the child process doesn't reset the
372 * parent's file descriptors to be blocking. This is a workaround for a
373 * limitation of userland libpthread on older versions of OpenBSD.
376 _thread_sys_closefrom(0);
377 #endif /* __OpenBSD__ && OpenBSD < 201211 */
380 * Since CoreFoundation and DBUS both create fork-unsafe data on execution of
381 * a program, and since this kind of really unfriendly behavior seems to be
382 * more common these days in system libraries, we need to re-execute the
383 * background cupsd with the "-C" option to avoid problems. Unfortunately,
384 * we also have to assume that argv[0] contains the name of the cupsd
385 * executable - there is no portable way to get the real pathname...
388 execlp(argv
[0], argv
[0], "-C", ConfigurationFile
, (char *)0);
395 * Make sure we aren't tying up any filesystems...
402 * Disable core dumps...
405 getrlimit(RLIMIT_CORE
, &limit
);
407 setrlimit(RLIMIT_CORE
, &limit
);
410 * Disconnect from the controlling terminal...
416 * Close all open files...
419 getrlimit(RLIMIT_NOFILE
, &limit
);
421 for (i
= 0; i
< limit
.rlim_cur
&& i
< 1024; i
++)
425 * Redirect stdin/out/err to /dev/null...
428 if ((i
= open("/dev/null", O_RDONLY
)) != 0)
434 if ((i
= open("/dev/null", O_WRONLY
)) != 1)
440 if ((i
= open("/dev/null", O_WRONLY
)) != 2)
449 * Set the timezone info...
455 setlocale(LC_TIME
, "");
459 * Set the maximum number of files...
462 getrlimit(RLIMIT_NOFILE
, &limit
);
464 #if !defined(HAVE_POLL) && !defined(HAVE_EPOLL) && !defined(HAVE_KQUEUE)
465 if (limit
.rlim_max
> FD_SETSIZE
)
468 #endif /* !HAVE_POLL && !HAVE_EPOLL && !HAVE_KQUEUE */
470 if (limit
.rlim_max
== RLIM_INFINITY
)
473 #endif /* RLIM_INFINITY */
474 MaxFDs
= limit
.rlim_max
;
476 limit
.rlim_cur
= MaxFDs
;
478 setrlimit(RLIMIT_NOFILE
, &limit
);
483 * Read configuration...
486 if (!cupsdReadConfiguration())
489 printf("%s contains errors\n", ConfigurationFile
);
491 syslog(LOG_LPR
, "Unable to read configuration file \'%s\' - exiting!",
495 else if (TestConfigFile
)
497 printf("%s is OK\n", ConfigurationFile
);
502 * Clean out old temp files and printer cache data.
505 if (!strncmp(TempDir
, RequestRoot
, strlen(RequestRoot
)))
506 cupsdCleanFiles(TempDir
, NULL
);
508 cupsdCleanFiles(CacheDir
, "*.ipp");
514 * If we were started by launchd get the listen sockets file descriptors...
520 #endif /* HAVE_LAUNCHD */
523 * Startup the server...
531 * Catch hangup and child signals and ignore broken pipes...
534 #ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */
535 sigset(SIGCHLD
, sigchld_handler
);
536 sigset(SIGHUP
, sighup_handler
);
537 sigset(SIGPIPE
, SIG_IGN
);
538 sigset(SIGTERM
, sigterm_handler
);
539 #elif defined(HAVE_SIGACTION)
540 memset(&action
, 0, sizeof(action
));
542 sigemptyset(&action
.sa_mask
);
543 sigaddset(&action
.sa_mask
, SIGTERM
);
544 sigaddset(&action
.sa_mask
, SIGCHLD
);
545 action
.sa_handler
= sigchld_handler
;
546 sigaction(SIGCHLD
, &action
, NULL
);
548 sigemptyset(&action
.sa_mask
);
549 sigaddset(&action
.sa_mask
, SIGHUP
);
550 action
.sa_handler
= sighup_handler
;
551 sigaction(SIGHUP
, &action
, NULL
);
553 sigemptyset(&action
.sa_mask
);
554 action
.sa_handler
= SIG_IGN
;
555 sigaction(SIGPIPE
, &action
, NULL
);
557 sigemptyset(&action
.sa_mask
);
558 sigaddset(&action
.sa_mask
, SIGTERM
);
559 sigaddset(&action
.sa_mask
, SIGCHLD
);
560 action
.sa_handler
= sigterm_handler
;
561 sigaction(SIGTERM
, &action
, NULL
);
563 signal(SIGCLD
, sigchld_handler
); /* No, SIGCLD isn't a typo... */
564 signal(SIGHUP
, sighup_handler
);
565 signal(SIGPIPE
, SIG_IGN
);
566 signal(SIGTERM
, sigterm_handler
);
567 #endif /* HAVE_SIGSET */
570 * Initialize authentication certificates...
576 * If we are running in the background, signal the parent process that
577 * we are up and running...
580 if (!fg
|| run_as_child
)
583 * Send a signal to the parent process, but only if the parent is
584 * not PID 1 (init). This avoids accidentally shutting down the
585 * system on OpenBSD if you CTRL-C the server before it is up...
588 i
= getppid(); /* Save parent PID to avoid race condition */
596 * Start power management framework...
600 cupsdStartSystemMonitor();
601 #endif /* __APPLE__ */
604 * Send server-started event...
609 cupsdAddEvent(CUPSD_EVENT_SERVER_STARTED
, NULL
, NULL
,
610 "Scheduler started via launchd.");
612 #endif /* HAVE_LAUNCHD */
614 cupsdAddEvent(CUPSD_EVENT_SERVER_STARTED
, NULL
, NULL
,
615 "Scheduler started in foreground.");
617 cupsdAddEvent(CUPSD_EVENT_SERVER_STARTED
, NULL
, NULL
,
618 "Scheduler started in background.");
621 * Start any pending print jobs...
630 current_time
= time(NULL
);
631 event_time
= current_time
;
632 expire_time
= current_time
;
635 senddoc_time
= current_time
;
637 while (!stop_scheduler
)
640 * Check if there are dead children to handle...
647 * Check if we need to load the server configuration file...
653 * Close any idle clients...
656 if (cupsArrayCount(Clients
) > 0)
658 for (con
= (cupsd_client_t
*)cupsArrayFirst(Clients
);
660 con
= (cupsd_client_t
*)cupsArrayNext(Clients
))
661 if (con
->http
.state
== HTTP_WAITING
)
662 cupsdCloseClient(con
);
664 con
->http
.keep_alive
= HTTP_KEEPALIVE_OFF
;
666 cupsdPauseListening();
670 * Restart if all clients are closed and all jobs finished, or
671 * if the reload timeout has elapsed...
674 if ((cupsArrayCount(Clients
) == 0 &&
675 (cupsArrayCount(PrintingJobs
) == 0 || NeedReload
!= RELOAD_ALL
)) ||
676 (time(NULL
) - ReloadTime
) >= ReloadTimeout
)
679 * Shutdown the server...
687 * Read configuration...
690 if (!cupsdReadConfiguration())
692 syslog(LOG_LPR
, "Unable to read configuration file \'%s\' - exiting!",
701 * If we were started by launchd, get the listen socket file
708 #endif /* HAVE_LAUNCHD */
711 * Startup the server...
719 * Send a server-restarted event...
722 cupsdAddEvent(CUPSD_EVENT_SERVER_RESTARTED
, NULL
, NULL
,
723 "Scheduler restarted.");
728 * Check for available input or ready output. If cupsdDoSelect()
729 * returns 0 or -1, something bad happened and we should exit
732 * Note that we at least have one listening socket open at all
736 if ((timeout
= select_timeout(fds
)) > 1 && LastEvent
)
741 * If no other work is scheduled and we're being controlled by
742 * launchd then timeout after 'LaunchdTimeout' seconds of
746 if (timeout
== 86400 && Launchd
&& LaunchdTimeout
&&
747 !cupsArrayCount(ActiveJobs
) &&
748 (!Browsing
|| !BrowseLocalProtocols
|| !cupsArrayCount(Printers
)))
750 timeout
= LaunchdTimeout
;
751 launchd_idle_exit
= 1;
754 launchd_idle_exit
= 0;
755 #endif /* HAVE_LAUNCHD */
757 if ((fds
= cupsdDoSelect(timeout
)) < 0)
760 * Got an error from select!
763 #if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
764 cupsd_printer_t
*p
; /* Current printer */
765 #endif /* HAVE_DNSSD || HAVE_AVAHI */
768 if (errno
== EINTR
) /* Just interrupted by a signal */
772 * Log all sorts of debug info to help track down the problem.
775 cupsdLogMessage(CUPSD_LOG_EMERG
, "cupsdDoSelect() failed - %s!",
778 for (i
= 0, con
= (cupsd_client_t
*)cupsArrayFirst(Clients
);
780 i
++, con
= (cupsd_client_t
*)cupsArrayNext(Clients
))
781 cupsdLogMessage(CUPSD_LOG_EMERG
,
782 "Clients[%d] = %d, file = %d, state = %d",
783 i
, con
->http
.fd
, con
->file
, con
->http
.state
);
785 for (i
= 0, lis
= (cupsd_listener_t
*)cupsArrayFirst(Listeners
);
787 i
++, lis
= (cupsd_listener_t
*)cupsArrayNext(Listeners
))
788 cupsdLogMessage(CUPSD_LOG_EMERG
, "Listeners[%d] = %d", i
, lis
->fd
);
790 cupsdLogMessage(CUPSD_LOG_EMERG
, "CGIPipes[0] = %d", CGIPipes
[0]);
793 cupsdLogMessage(CUPSD_LOG_EMERG
, "SysEventPipes[0] = %d",
795 #endif /* __APPLE__ */
797 for (job
= (cupsd_job_t
*)cupsArrayFirst(ActiveJobs
);
799 job
= (cupsd_job_t
*)cupsArrayNext(ActiveJobs
))
800 cupsdLogMessage(CUPSD_LOG_EMERG
, "Jobs[%d] = %d < [%d %d] > [%d %d]",
802 job
->status_buffer
? job
->status_buffer
->fd
: -1,
803 job
->print_pipes
[0], job
->print_pipes
[1],
804 job
->back_pipes
[0], job
->back_pipes
[1]);
806 #if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
807 for (p
= (cupsd_printer_t
*)cupsArrayFirst(Printers
);
809 p
= (cupsd_printer_t
*)cupsArrayNext(Printers
))
810 cupsdLogMessage(CUPSD_LOG_EMERG
, "printer[%s] reg_name=\"%s\"", p
->name
,
811 p
->reg_name
? p
->reg_name
: "(null)");
812 #endif /* HAVE_DNSSD || HAVE_AVAHI */
817 current_time
= time(NULL
);
820 * Write dirty config/state files...
823 if (DirtyCleanTime
&& current_time
>= DirtyCleanTime
)
828 * If we are going to sleep and still have pending jobs, stop them after
829 * a period of time...
832 if (SleepJobs
> 0 && current_time
>= SleepJobs
&&
833 cupsArrayCount(PrintingJobs
) > 0)
836 cupsdStopAllJobs(CUPSD_JOB_DEFAULT
, 5);
838 #endif /* __APPLE__ */
842 * Update the network interfaces once a minute...
845 if ((current_time
- netif_time
) >= 60)
847 netif_time
= current_time
;
850 #endif /* !__APPLE__ */
854 * If no other work was scheduled and we're being controlled by launchd
855 * then timeout after 'LaunchdTimeout' seconds of inactivity...
858 if (!fds
&& launchd_idle_exit
)
860 cupsdLogMessage(CUPSD_LOG_INFO
,
861 "Printer sharing is off and there are no jobs pending, "
862 "will restart on demand.");
866 #endif /* HAVE_LAUNCHD */
869 * Resume listening for new connections as needed...
872 if (ListeningPaused
&& ListeningPaused
<= current_time
&&
873 cupsArrayCount(Clients
) < MaxClients
)
874 cupsdResumeListening();
877 * Expire subscriptions and unload completed jobs as needed...
880 if (current_time
> expire_time
)
882 if (cupsArrayCount(Subscriptions
) > 0)
883 cupsdExpireSubscriptions(NULL
, NULL
);
885 cupsdUnloadCompletedJobs();
887 expire_time
= current_time
;
890 #ifndef HAVE_AUTHORIZATION_H
892 * Update the root certificate once every 5 minutes if we have client
896 if ((current_time
- RootCertTime
) >= RootCertDuration
&& RootCertDuration
&&
897 !RunUser
&& cupsArrayCount(Clients
))
900 * Update the root certificate...
904 cupsdAddCert(0, "root", NULL
);
906 #endif /* !HAVE_AUTHORIZATION_H */
909 * Check for new data on the client sockets...
912 for (con
= (cupsd_client_t
*)cupsArrayFirst(Clients
);
914 con
= (cupsd_client_t
*)cupsArrayNext(Clients
))
917 * Process pending data in the input buffer...
922 cupsdReadClient(con
);
927 * Check the activity and close old clients...
930 activity
= current_time
- Timeout
;
931 if (con
->http
.activity
< activity
&& !con
->pipe_pid
)
933 cupsdLogMessage(CUPSD_LOG_DEBUG
,
934 "Closing client %d after %d seconds of inactivity...",
935 con
->http
.fd
, Timeout
);
937 cupsdCloseClient(con
);
943 * Update any pending multi-file documents...
946 if ((current_time
- senddoc_time
) >= 10)
949 senddoc_time
= current_time
;
953 * Clean job history...
956 if (JobHistoryUpdate
&& current_time
>= JobHistoryUpdate
)
960 * Log statistics at most once a minute when in debug mode...
963 if ((current_time
- report_time
) >= 60 && LogLevel
>= CUPSD_LOG_DEBUG
)
965 size_t string_count
, /* String count */
966 alloc_bytes
, /* Allocated string bytes */
967 total_bytes
; /* Total string bytes */
969 struct mallinfo mem
; /* Malloc information */
973 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Report: malloc-arena=%lu", mem
.arena
);
974 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Report: malloc-used=%lu",
975 mem
.usmblks
+ mem
.uordblks
);
976 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Report: malloc-free=%lu",
977 mem
.fsmblks
+ mem
.fordblks
);
978 #endif /* HAVE_MALLINFO */
980 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Report: clients=%d",
981 cupsArrayCount(Clients
));
982 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Report: jobs=%d",
983 cupsArrayCount(Jobs
));
984 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Report: jobs-active=%d",
985 cupsArrayCount(ActiveJobs
));
986 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Report: printers=%d",
987 cupsArrayCount(Printers
));
989 string_count
= _cupsStrStatistics(&alloc_bytes
, &total_bytes
);
990 cupsdLogMessage(CUPSD_LOG_DEBUG
,
991 "Report: stringpool-string-count=" CUPS_LLFMT
,
992 CUPS_LLCAST string_count
);
993 cupsdLogMessage(CUPSD_LOG_DEBUG
,
994 "Report: stringpool-alloc-bytes=" CUPS_LLFMT
,
995 CUPS_LLCAST alloc_bytes
);
996 cupsdLogMessage(CUPSD_LOG_DEBUG
,
997 "Report: stringpool-total-bytes=" CUPS_LLFMT
,
998 CUPS_LLCAST total_bytes
);
1000 report_time
= current_time
;
1004 * Handle OS-specific event notification for any events that have
1005 * accumulated. Don't send these more than once a second...
1008 if (LastEvent
&& (current_time
- event_time
) >= 1)
1010 #ifdef HAVE_NOTIFY_POST
1011 if (LastEvent
& (CUPSD_EVENT_PRINTER_ADDED
|
1012 CUPSD_EVENT_PRINTER_DELETED
|
1013 CUPSD_EVENT_PRINTER_MODIFIED
))
1015 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1016 "notify_post(\"com.apple.printerListChange\")");
1017 notify_post("com.apple.printerListChange");
1020 if (LastEvent
& CUPSD_EVENT_PRINTER_STATE_CHANGED
)
1022 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1023 "notify_post(\"com.apple.printerHistoryChange\")");
1024 notify_post("com.apple.printerHistoryChange");
1027 if (LastEvent
& (CUPSD_EVENT_JOB_STATE_CHANGED
|
1028 CUPSD_EVENT_JOB_CONFIG_CHANGED
|
1029 CUPSD_EVENT_JOB_PROGRESS
))
1031 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1032 "notify_post(\"com.apple.jobChange\")");
1033 notify_post("com.apple.jobChange");
1035 #endif /* HAVE_NOTIFY_POST */
1038 * Reset the accumulated events...
1041 LastEvent
= CUPSD_EVENT_NONE
;
1042 event_time
= current_time
;
1047 * Log a message based on what happened...
1052 cupsdLogMessage(CUPSD_LOG_INFO
, "Scheduler shutting down normally.");
1053 cupsdAddEvent(CUPSD_EVENT_SERVER_STOPPED
, NULL
, NULL
,
1054 "Scheduler shutting down normally.");
1058 cupsdLogMessage(CUPSD_LOG_ERROR
,
1059 "Scheduler shutting down due to program error.");
1060 cupsdAddEvent(CUPSD_EVENT_SERVER_STOPPED
, NULL
, NULL
,
1061 "Scheduler shutting down due to program error.");
1065 * Close all network clients...
1074 * Update the launchd KeepAlive file as needed...
1079 #endif /* HAVE_LAUNCHD */
1089 * Stop monitoring system event monitoring...
1093 cupsdStopSystemMonitor();
1094 #endif /* __APPLE__ */
1098 * Free the scheduler's Kerberos context...
1103 * If the weak-linked GSSAPI/Kerberos library is not present, don't try
1107 if (krb5_init_context
!= NULL
)
1108 # endif /* __APPLE__ */
1109 if (KerberosContext
)
1110 krb5_free_context(KerberosContext
);
1111 #endif /* HAVE_GSSAPI */
1115 return (!stop_scheduler
);
1120 * 'cupsdAddString()' - Copy and add a string to an array.
1123 int /* O - 1 on success, 0 on failure */
1124 cupsdAddString(cups_array_t
**a
, /* IO - String array */
1125 const char *s
) /* I - String to copy and add */
1128 *a
= cupsArrayNew3((cups_array_func_t
)strcmp
, NULL
,
1129 (cups_ahash_func_t
)NULL
, 0,
1130 (cups_acopy_func_t
)_cupsStrAlloc
,
1131 (cups_afree_func_t
)_cupsStrFree
);
1133 return (cupsArrayAdd(*a
, (char *)s
));
1138 * 'cupsdCheckProcess()' - Tell the main loop to check for dead children.
1142 cupsdCheckProcess(void)
1145 * Flag that we have dead children...
1153 * 'cupsdClearString()' - Clear a string.
1157 cupsdClearString(char **s
) /* O - String value */
1168 * 'cupsdFreeStrings()' - Free an array of strings.
1172 cupsdFreeStrings(cups_array_t
**a
) /* IO - String array */
1176 cupsArrayDelete(*a
);
1183 * 'cupsdHoldSignals()' - Hold child and termination signals.
1187 cupsdHoldSignals(void)
1189 #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
1190 sigset_t newmask
; /* New POSIX signal mask */
1191 #endif /* HAVE_SIGACTION && !HAVE_SIGSET */
1201 #elif defined(HAVE_SIGACTION)
1202 sigemptyset(&newmask
);
1203 sigaddset(&newmask
, SIGTERM
);
1204 sigaddset(&newmask
, SIGCHLD
);
1205 sigprocmask(SIG_BLOCK
, &newmask
, &holdmask
);
1206 #endif /* HAVE_SIGSET */
1211 * 'cupsdReleaseSignals()' - Release signals for delivery.
1215 cupsdReleaseSignals(void)
1224 #elif defined(HAVE_SIGACTION)
1225 sigprocmask(SIG_SETMASK
, &holdmask
, NULL
);
1226 #endif /* HAVE_SIGSET */
1231 * 'cupsdSetString()' - Set a string value.
1235 cupsdSetString(char **s
, /* O - New string */
1236 const char *v
) /* I - String value */
1245 *s
= _cupsStrAlloc(v
);
1252 * 'cupsdSetStringf()' - Set a formatted string value.
1256 cupsdSetStringf(char **s
, /* O - New string */
1257 const char *f
, /* I - Printf-style format string */
1258 ...) /* I - Additional args as needed */
1260 char v
[4096]; /* Formatting string value */
1261 va_list ap
; /* Argument pointer */
1262 char *olds
; /* Old string */
1273 vsnprintf(v
, sizeof(v
), f
, ap
);
1276 *s
= _cupsStrAlloc(v
);
1288 * 'launchd_checkin()' - Check-in with launchd and collect the listening fds.
1292 launchd_checkin(void)
1294 size_t i
, /* Looping var */
1295 count
; /* Number of listeners */
1296 launch_data_t ld_msg
, /* Launch data message */
1297 ld_resp
, /* Launch data response */
1298 ld_array
, /* Launch data array */
1299 ld_sockets
, /* Launch data sockets dictionary */
1300 tmp
; /* Launch data */
1301 cupsd_listener_t
*lis
; /* Listeners array */
1302 http_addr_t addr
; /* Address variable */
1303 socklen_t addrlen
; /* Length of address */
1304 int fd
; /* File descriptor */
1305 char s
[256]; /* String addresss */
1308 cupsdLogMessage(CUPSD_LOG_DEBUG
, "launchd_checkin: pid=%d", (int)getpid());
1311 * Check-in with launchd...
1314 ld_msg
= launch_data_new_string(LAUNCH_KEY_CHECKIN
);
1315 if ((ld_resp
= launch_msg(ld_msg
)) == NULL
)
1317 cupsdLogMessage(CUPSD_LOG_ERROR
,
1318 "launchd_checkin: launch_msg(\"" LAUNCH_KEY_CHECKIN
1321 return; /* anti-compiler-warning */
1324 if (launch_data_get_type(ld_resp
) == LAUNCH_DATA_ERRNO
)
1326 errno
= launch_data_get_errno(ld_resp
);
1327 cupsdLogMessage(CUPSD_LOG_ERROR
, "launchd_checkin: Check-in failed: %s",
1330 return; /* anti-compiler-warning */
1334 * Get the sockets dictionary...
1337 if ((ld_sockets
= launch_data_dict_lookup(ld_resp
, LAUNCH_JOBKEY_SOCKETS
))
1340 cupsdLogMessage(CUPSD_LOG_ERROR
,
1341 "launchd_checkin: No sockets found to answer requests on!");
1343 return; /* anti-compiler-warning */
1347 * Get the array of listener sockets...
1350 if ((ld_array
= launch_data_dict_lookup(ld_sockets
, "Listeners")) == NULL
)
1352 cupsdLogMessage(CUPSD_LOG_ERROR
,
1353 "launchd_checkin: No sockets found to answer requests on!");
1355 return; /* anti-compiler-warning */
1359 * Add listening fd(s) to the Listener array...
1362 if (launch_data_get_type(ld_array
) == LAUNCH_DATA_ARRAY
)
1364 count
= launch_data_array_get_count(ld_array
);
1366 for (i
= 0; i
< count
; i
++)
1369 * Get the launchd file descriptor and address...
1372 if ((tmp
= launch_data_array_get_index(ld_array
, i
)) != NULL
)
1374 fd
= launch_data_get_fd(tmp
);
1375 addrlen
= sizeof(addr
);
1377 if (getsockname(fd
, (struct sockaddr
*)&addr
, &addrlen
))
1379 cupsdLogMessage(CUPSD_LOG_ERROR
,
1380 "launchd_checkin: Unable to get local address - %s",
1386 * Try to match the launchd socket address to one of the listeners...
1389 for (lis
= (cupsd_listener_t
*)cupsArrayFirst(Listeners
);
1391 lis
= (cupsd_listener_t
*)cupsArrayNext(Listeners
))
1392 if (httpAddrEqual(&lis
->address
, &addr
))
1396 * Add a new listener If there's no match...
1401 cupsdLogMessage(CUPSD_LOG_DEBUG
,
1402 "launchd_checkin: Matched existing listener %s with fd %d...",
1403 httpAddrString(&(lis
->address
), s
, sizeof(s
)), fd
);
1407 cupsdLogMessage(CUPSD_LOG_DEBUG
,
1408 "launchd_checkin: Adding new listener %s with fd %d...",
1409 httpAddrString(&addr
, s
, sizeof(s
)), fd
);
1411 if ((lis
= calloc(1, sizeof(cupsd_listener_t
))) == NULL
)
1413 cupsdLogMessage(CUPSD_LOG_ERROR
,
1414 "launchd_checkin: Unable to allocate listener - "
1415 "%s.", strerror(errno
));
1419 cupsArrayAdd(Listeners
, lis
);
1421 memcpy(&lis
->address
, &addr
, sizeof(lis
->address
));
1427 if (httpAddrPort(&(lis
->address
)) == 443)
1428 lis
->encryption
= HTTP_ENCRYPT_ALWAYS
;
1429 # endif /* HAVE_SSL */
1434 launch_data_free(ld_msg
);
1435 launch_data_free(ld_resp
);
1440 * 'launchd_checkout()' - Update the launchd KeepAlive file as needed.
1444 launchd_checkout(void)
1446 int fd
; /* File descriptor */
1450 * Create or remove the launchd KeepAlive file based on whether
1451 * there are active jobs, polling, browsing for remote printers or
1452 * shared printers to advertise...
1455 if (cupsArrayCount(ActiveJobs
) ||
1456 (Browsing
&& BrowseLocalProtocols
&& cupsArrayCount(Printers
)))
1458 cupsdLogMessage(CUPSD_LOG_DEBUG
,
1459 "Creating launchd keepalive file \"" CUPS_KEEPALIVE
1462 if ((fd
= open(CUPS_KEEPALIVE
, O_RDONLY
| O_CREAT
| O_EXCL
, S_IRUSR
)) >= 0)
1467 cupsdLogMessage(CUPSD_LOG_DEBUG
,
1468 "Removing launchd keepalive file \"" CUPS_KEEPALIVE
1471 unlink(CUPS_KEEPALIVE
);
1474 #endif /* HAVE_LAUNCHD */
1478 * 'parent_handler()' - Catch USR1/CHLD signals...
1482 parent_handler(int sig
) /* I - Signal */
1485 * Store the signal we got from the OS and return...
1488 parent_signal
= sig
;
1493 * 'process_children()' - Process all dead children...
1497 process_children(void)
1499 int status
; /* Exit status of child */
1500 int pid
, /* Process ID of child */
1501 job_id
; /* Job ID of child */
1502 cupsd_job_t
*job
; /* Current job */
1503 int i
; /* Looping var */
1504 char name
[1024]; /* Process name */
1505 const char *type
; /* Type of program */
1508 cupsdLogMessage(CUPSD_LOG_DEBUG2
, "process_children()");
1511 * Reset the dead_children flag...
1517 * Collect the exit status of some children...
1521 while ((pid
= waitpid(-1, &status
, WNOHANG
)) > 0)
1522 #elif defined(HAVE_WAIT3)
1523 while ((pid
= wait3(&status
, WNOHANG
, NULL
)) > 0)
1525 if ((pid
= wait(&status
)) > 0)
1526 #endif /* HAVE_WAITPID */
1529 * Collect the name of the process that finished...
1532 cupsdFinishProcess(pid
, name
, sizeof(name
), &job_id
);
1535 * Delete certificates for CGI processes...
1539 cupsdDeleteCert(pid
);
1542 * Handle completed job filters...
1546 job
= cupsdFindJob(job_id
);
1552 for (i
= 0; job
->filters
[i
]; i
++)
1553 if (job
->filters
[i
] == pid
)
1556 if (job
->filters
[i
] || job
->backend
== pid
)
1559 * OK, this process has gone away; what's left?
1562 if (job
->filters
[i
])
1564 job
->filters
[i
] = -pid
;
1569 job
->backend
= -pid
;
1573 if (status
&& status
!= SIGTERM
&& status
!= SIGKILL
&&
1577 * An error occurred; save the exit status so we know to stop
1578 * the printer or cancel the job when all of the filters finish...
1580 * A negative status indicates that the backend failed and the
1581 * printer needs to be stopped.
1583 * In order to preserve the most serious status, we always log
1584 * when a process dies due to a signal (e.g. SIGABRT, SIGSEGV,
1585 * and SIGBUS) and prefer to log the backend exit status over a
1589 int old_status
= abs(job
->status
);
1591 if (WIFSIGNALED(status
) || /* This process crashed, or */
1592 !job
->status
|| /* No process had a status, or */
1593 (!job
->filters
[i
] && WIFEXITED(old_status
)))
1594 { /* Backend and filter didn't crash */
1595 if (job
->filters
[i
])
1596 job
->status
= status
; /* Filter failed */
1598 job
->status
= -status
; /* Backend failed */
1601 if (job
->state_value
== IPP_JOB_PROCESSING
&&
1602 job
->status_level
> CUPSD_LOG_ERROR
&&
1603 (job
->filters
[i
] || !WIFEXITED(status
)))
1605 char message
[1024]; /* New printer-state-message */
1608 job
->status_level
= CUPSD_LOG_ERROR
;
1610 snprintf(message
, sizeof(message
), "%s failed", type
);
1614 strlcpy(job
->printer
->state_message
, message
,
1615 sizeof(job
->printer
->state_message
));
1621 if (!job
->printer_message
&& job
->attrs
)
1623 if ((job
->printer_message
=
1624 ippFindAttribute(job
->attrs
, "job-printer-state-message",
1625 IPP_TAG_TEXT
)) == NULL
)
1626 job
->printer_message
= ippAddString(job
->attrs
, IPP_TAG_JOB
,
1628 "job-printer-state-message",
1632 if (job
->printer_message
)
1633 cupsdSetString(&(job
->printer_message
->values
[0].string
.text
),
1639 * If this is not the last file in a job, see if all of the
1640 * filters are done, and if so move to the next file.
1643 if (job
->current_file
< job
->num_files
&& job
->printer
)
1645 for (i
= 0; job
->filters
[i
] < 0; i
++);
1647 if (!job
->filters
[i
] &&
1648 (!job
->printer
->pc
|| !job
->printer
->pc
->single_file
||
1652 * Process the next file...
1655 cupsdContinueJob(job
);
1658 else if (job
->state_value
>= IPP_JOB_CANCELED
)
1661 * Remove the job from the active list if there are no processes still
1665 for (i
= 0; job
->filters
[i
] < 0; i
++);
1667 if (!job
->filters
[i
] && job
->backend
<= 0)
1668 cupsArrayRemove(ActiveJobs
, job
);
1674 * Show the exit status as needed, ignoring SIGTERM and SIGKILL errors
1675 * since they come when we kill/end a process...
1678 if (status
== SIGTERM
|| status
== SIGKILL
)
1680 cupsdLogJob(job
, CUPSD_LOG_DEBUG
,
1681 "PID %d (%s) was terminated normally with signal %d.", pid
,
1684 else if (status
== SIGPIPE
)
1686 cupsdLogJob(job
, CUPSD_LOG_DEBUG
,
1687 "PID %d (%s) did not catch or ignore signal %d.", pid
, name
,
1692 if (WIFEXITED(status
))
1694 int code
= WEXITSTATUS(status
); /* Exit code */
1697 cupsdLogJob(job
, CUPSD_LOG_DEBUG
,
1698 "PID %d (%s) stopped with status %d (%s)", pid
, name
,
1699 code
, strerror(code
- 100));
1701 cupsdLogJob(job
, CUPSD_LOG_DEBUG
,
1702 "PID %d (%s) stopped with status %d.", pid
, name
, code
);
1705 cupsdLogJob(job
, CUPSD_LOG_DEBUG
, "PID %d (%s) crashed on signal %d.",
1706 pid
, name
, WTERMSIG(status
));
1708 if (LogLevel
< CUPSD_LOG_DEBUG
)
1709 cupsdLogJob(job
, CUPSD_LOG_INFO
,
1710 "Hint: Try setting the LogLevel to \"debug\" to find out "
1714 cupsdLogJob(job
, CUPSD_LOG_DEBUG
, "PID %d (%s) exited with no errors.",
1719 * If wait*() is interrupted by a signal, tell main() to call us again...
1722 if (pid
< 0 && errno
== EINTR
)
1728 * 'select_timeout()' - Calculate the select timeout value.
1732 static long /* O - Number of seconds */
1733 select_timeout(int fds
) /* I - Number of descriptors returned */
1735 long timeout
; /* Timeout for select */
1736 time_t now
; /* Current time */
1737 cupsd_client_t
*con
; /* Client information */
1738 cupsd_job_t
*job
; /* Job information */
1739 cupsd_subscription_t
*sub
; /* Subscription information */
1740 const char *why
; /* Debugging aid */
1743 cupsdLogMessage(CUPSD_LOG_DEBUG2
, "select_timeout: JobHistoryUpdate=%ld",
1744 (long)JobHistoryUpdate
);
1747 * Check to see if any of the clients have pending data to be
1748 * processed; if so, the timeout should be 0...
1751 for (con
= (cupsd_client_t
*)cupsArrayFirst(Clients
);
1753 con
= (cupsd_client_t
*)cupsArrayNext(Clients
))
1754 if (con
->http
.used
> 0)
1758 * If select has been active in the last second (fds > 0) or we have
1759 * many resources in use then don't bother trying to optimize the
1760 * timeout, just make it 1 second.
1763 if (fds
> 0 || cupsArrayCount(Clients
) > 50)
1767 * Otherwise, check all of the possible events that we need to wake for...
1771 timeout
= now
+ 86400; /* 86400 == 1 day */
1776 * When going to sleep, wake up to cancel jobs that don't complete in time.
1779 if (SleepJobs
> 0 && SleepJobs
< timeout
)
1781 timeout
= SleepJobs
;
1782 why
= "cancel jobs before sleeping";
1784 #endif /* __APPLE__ */
1787 * Check whether we are accepting new connections...
1790 if (ListeningPaused
> 0 && cupsArrayCount(Clients
) < MaxClients
&&
1791 ListeningPaused
< timeout
)
1793 if (ListeningPaused
<= now
)
1796 timeout
= ListeningPaused
;
1798 why
= "resume listening";
1802 * Check the activity and close old clients...
1805 for (con
= (cupsd_client_t
*)cupsArrayFirst(Clients
);
1807 con
= (cupsd_client_t
*)cupsArrayNext(Clients
))
1808 if ((con
->http
.activity
+ Timeout
) < timeout
)
1810 timeout
= con
->http
.activity
+ Timeout
;
1811 why
= "timeout a client connection";
1815 * Write out changes to configuration and state files...
1818 if (DirtyCleanTime
&& timeout
> DirtyCleanTime
)
1820 timeout
= DirtyCleanTime
;
1821 why
= "write dirty config/state files";
1825 * Check for any job activity...
1828 if (JobHistoryUpdate
&& timeout
> JobHistoryUpdate
)
1830 timeout
= JobHistoryUpdate
;
1831 why
= "update job history";
1834 for (job
= (cupsd_job_t
*)cupsArrayFirst(ActiveJobs
);
1836 job
= (cupsd_job_t
*)cupsArrayNext(ActiveJobs
))
1838 if (job
->cancel_time
&& job
->cancel_time
< timeout
)
1840 timeout
= job
->cancel_time
;
1841 why
= "cancel stuck jobs";
1844 if (job
->kill_time
&& job
->kill_time
< timeout
)
1846 timeout
= job
->kill_time
;
1847 why
= "kill unresponsive jobs";
1850 if (job
->state_value
== IPP_JOB_HELD
&& job
->hold_until
< timeout
)
1852 timeout
= job
->hold_until
;
1853 why
= "release held jobs";
1856 if (job
->state_value
== IPP_JOB_PENDING
&& timeout
> (now
+ 10))
1859 why
= "start pending jobs";
1864 #ifdef HAVE_MALLINFO
1866 * Log memory usage every minute...
1869 if (LogLevel
>= CUPSD_LOG_DEBUG
&& (mallinfo_time
+ 60) < timeout
)
1871 timeout
= mallinfo_time
+ 60;
1872 why
= "display memory usage";
1874 #endif /* HAVE_MALLINFO */
1877 * Expire subscriptions as needed...
1880 for (sub
= (cupsd_subscription_t
*)cupsArrayFirst(Subscriptions
);
1882 sub
= (cupsd_subscription_t
*)cupsArrayNext(Subscriptions
))
1883 if (!sub
->job
&& sub
->expire
&& sub
->expire
< timeout
)
1885 timeout
= sub
->expire
;
1886 why
= "expire subscription";
1890 * Adjust from absolute to relative time. We add 1 second to the timeout since
1891 * events occur after the timeout expires, and limit the timeout to 86400
1892 * seconds (1 day) to avoid select() timeout limits present on some operating
1896 timeout
= timeout
- now
+ 1;
1900 else if (timeout
> 86400)
1904 * Log and return the timeout value...
1907 cupsdLogMessage(CUPSD_LOG_DEBUG2
, "select_timeout(%d): %ld seconds to %s",
1915 * 'sigchld_handler()' - Handle 'child' signals from old processes.
1919 sigchld_handler(int sig
) /* I - Signal number */
1924 * Flag that we have dead children...
1930 * Reset the signal handler as needed...
1933 #if !defined(HAVE_SIGSET) && !defined(HAVE_SIGACTION)
1934 signal(SIGCLD
, sigchld_handler
);
1935 #endif /* !HAVE_SIGSET && !HAVE_SIGACTION */
1940 * 'sighup_handler()' - Handle 'hangup' signals to reconfigure the scheduler.
1944 sighup_handler(int sig
) /* I - Signal number */
1948 NeedReload
= RELOAD_ALL
;
1949 ReloadTime
= time(NULL
);
1951 #if !defined(HAVE_SIGSET) && !defined(HAVE_SIGACTION)
1952 signal(SIGHUP
, sighup_handler
);
1953 #endif /* !HAVE_SIGSET && !HAVE_SIGACTION */
1958 * 'sigterm_handler()' - Handle 'terminate' signals that stop the scheduler.
1962 sigterm_handler(int sig
) /* I - Signal number */
1964 (void)sig
; /* remove compiler warnings... */
1967 * Flag that we should stop and return...
1975 * 'usage()' - Show scheduler usage.
1979 usage(int status
) /* O - Exit status */
1981 FILE *fp
= status
? stderr
: stdout
; /* Output file */
1984 _cupsLangPuts(fp
, _("Usage: cupsd [options]"));
1985 _cupsLangPuts(fp
, _("Options:"));
1986 _cupsLangPuts(fp
, _(" -c cupsd.conf Set cupsd.conf file to use."));
1987 _cupsLangPuts(fp
, _(" -f Run in the foreground."));
1988 _cupsLangPuts(fp
, _(" -F Run in the foreground but "
1989 "detach from console."));
1990 _cupsLangPuts(fp
, _(" -h Show this usage message."));
1991 _cupsLangPuts(fp
, _(" -l Run cupsd from launchd(8)."));
1992 _cupsLangPuts(fp
, _(" -t Test the configuration "
2000 * End of "$Id: main.c 7925 2008-09-10 17:47:26Z mike $".