1
Description: Add support for creating pid files.
2
Author: Martin Pitt <mpitt@debian.org>
3
Bug: http://www.cups.org/str.php?L2465
5
Last-Update: 2015-02-10
10
#ifdef HAVE_AUTHORIZATION_H
11
{ "SystemGroupAuthKey", &SystemGroupAuthKey, CUPSD_VARTYPE_STRING },
12
#endif /* HAVE_AUTHORIZATION_H */
13
- { "TempDir", &TempDir, CUPSD_VARTYPE_PATHNAME }
14
+ { "TempDir", &TempDir, CUPSD_VARTYPE_PATHNAME },
15
+ { "PidFile", &PidFile, CUPSD_VARTYPE_STRING }
18
static int default_auth_type = CUPSD_AUTH_AUTO;
20
cupsdSetStringf(&ServerHeader, "CUPS/%d.%d IPP/2.1", CUPS_VERSION_MAJOR,
22
cupsdSetString(&StateDir, CUPS_STATEDIR);
23
+ cupsdSetString(&PidFile, "/var/run/cups/cupsd.pid");
25
if (!strcmp(CUPS_DEFAULT_PRINTCAP, "/etc/printers.conf"))
26
PrintcapFormat = PRINTCAP_SOLARIS;
28
!_cups_strcasecmp(line, "SystemGroup") ||
29
!_cups_strcasecmp(line, "SystemGroupAuthKey") ||
30
!_cups_strcasecmp(line, "TempDir") ||
31
+ !_cups_strcasecmp(line, "PidFile") ||
32
!_cups_strcasecmp(line, "User"))
34
cupsdLogMessage(CUPSD_LOG_INFO,
35
--- a/scheduler/conf.h
36
+++ b/scheduler/conf.h
38
VAR char *ServerKeychain VALUE(NULL);
39
/* Keychain holding cert + key */
41
+VAR char *PidFile VALUE(NULL);
42
+ /* Debian CUPS pid file */
44
#if defined(HAVE_LAUNCHD) || defined(HAVE_SYSTEMD)
45
VAR int IdleExitTimeout VALUE(60);
46
--- a/scheduler/main.c
47
+++ b/scheduler/main.c
49
static void service_checkout(void);
50
#endif /* HAVE_LAUNCHD || HAVE_SYSTEMD */
51
static void usage(int status) __attribute__((noreturn));
53
+int remove_pid(void);
58
cupsdStartSystemMonitor();
59
#endif /* __APPLE__ */
61
+ if (write_pid() == 0) {
62
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to write pid file");
67
* Send server-started event...
69
@@ -1162,10 +1169,41 @@
75
return (!stop_scheduler);
79
+/* 'write_pid()' - Write PID file.
80
+ 'remove_pid()' - Delete PID file.
88
+ if (((fd = open(PidFile, O_RDWR|O_CREAT, 0644)) == -1)
89
+ || ((f = fdopen(fd, "r+")) == NULL) ) {
93
+ if (!fprintf(f, "%d\n", pid)) {
105
+ return unlink(PidFile);
109
* 'cupsdAddString()' - Copy and add a string to an array.
111
--- a/test/run-stp-tests.sh
112
+++ b/test/run-stp-tests.sh
114
DocumentRoot $root/doc
115
RequestRoot $BASE/spool
116
TempDir $BASE/spool/temp
117
+PidFile $BASE/cupsd.pid
118
AccessLog $BASE/log/access_log
119
ErrorLog $BASE/log/error_log
120
PageLog $BASE/log/page_log