--- scheduler/conf.c.orig 2009-01-25 12:03:35.000000000 +0100 +++ scheduler/conf.c 2009-01-25 12:03:37.000000000 +0100 @@ -169,7 +169,8 @@ #endif /* HAVE_AUTHORIZATION_H */ { "TempDir", &TempDir, CUPSD_VARTYPE_PATHNAME }, { "Timeout", &Timeout, CUPSD_VARTYPE_INTEGER }, - { "UseNetworkDefault", &UseNetworkDefault, CUPSD_VARTYPE_BOOLEAN } + { "UseNetworkDefault", &UseNetworkDefault, CUPSD_VARTYPE_BOOLEAN }, + { "PidFile", &PidFile, CUPSD_VARTYPE_STRING } }; #define NUM_VARS (sizeof(variables) / sizeof(variables[0])) @@ -434,6 +435,7 @@ cupsdSetString(&RemoteRoot, "remroot"); cupsdSetString(&ServerHeader, "CUPS/1.3"); cupsdSetString(&StateDir, CUPS_STATEDIR); + cupsdSetString(&PidFile, "/var/run/cups/cupsd.pid"); #ifdef HAVE_GSSAPI cupsdSetString(&GSSServiceName, CUPS_DEFAULT_GSSSERVICENAME); #endif /* HAVE_GSSAPI */ --- scheduler/conf.h.orig 2008-02-16 00:26:51.000000000 +0100 +++ scheduler/conf.h 2009-01-25 12:03:37.000000000 +0100 @@ -189,6 +189,7 @@ /* Server key file */ # endif /* HAVE_LIBSSL || HAVE_GNUTLS */ #endif /* HAVE_SSL */ +VAR char *PidFile VALUE(NULL); /* Debian CUPS pid file */ #ifdef HAVE_LAUNCHD VAR int LaunchdTimeout VALUE(DEFAULT_TIMEOUT); --- scheduler/main.c.orig 2008-09-07 23:58:01.000000000 +0200 +++ scheduler/main.c 2009-01-25 12:03:37.000000000 +0100 @@ -89,6 +89,8 @@ static void sigterm_handler(int sig); static long select_timeout(int fds); static void usage(int status); +int write_pid(void); +int remove_pid(void); /* @@ -596,6 +598,11 @@ } #endif /* __sgi */ + if (write_pid() == 0) { + cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to write pid file"); + return (1); + } + /* * Initialize authentication certificates... */ @@ -1182,9 +1189,39 @@ cupsdStopSelect(); + remove_pid(); + return (!stop_scheduler); } +/* 'write_pid()' - Write PID file. + 'remove_pid()' - Delete PID file. +*/ +int +write_pid() +{ + FILE *f; + int fd; + int pid; + if (((fd = open(PidFile, O_RDWR|O_CREAT, 0644)) == -1) + || ((f = fdopen(fd, "r+")) == NULL) ) { + return 0; + } + pid = getpid(); + if (!fprintf(f, "%d\n", pid)) { + close(fd); + return 0; + } + fflush(f); + close(fd); + + return pid; +} + +int remove_pid() { + return unlink(PidFile); +} + /* * 'cupsdClosePipe()' - Close a pipe as necessary. --- test/run-stp-tests.sh.orig 2009-01-25 12:03:37.000000000 +0100 +++ test/run-stp-tests.sh 2009-01-25 12:03:59.000000000 +0100 @@ -307,6 +307,7 @@ DocumentRoot $root/doc RequestRoot /tmp/cups-$user/spool TempDir /tmp/cups-$user/spool/temp +PidFile /tmp/cups-$user/cupsd.pid MaxLogSize 0 AccessLog /tmp/cups-$user/log/access_log