[Pkg-cups-devel] r13 - in cupsys/trunk/debian: . patches

Kenshi Muto kmuto at costa.debian.org
Mon Aug 15 15:05:40 UTC 2005


Author: kmuto
Date: Mon Aug 15 15:05:39 2005
New Revision: 13

Added:
   cupsys/trunk/debian/patches/47_pid.dpatch   (contents, props changed)
Modified:
   cupsys/trunk/debian/changelog
Log:
add forked PID file patch.

Modified: cupsys/trunk/debian/changelog
==============================================================================
--- cupsys/trunk/debian/changelog	(original)
+++ cupsys/trunk/debian/changelog	Mon Aug 15 15:05:39 2005
@@ -8,6 +8,8 @@
     transitional package.
   * Add procps to Depends: of cupsys. ps command is used by
     cupsys.postinst.
+  * 47_pid.dpatch: Added a patch to make forked PID file. Needs more
+    review.
 
  -- Kenshi Muto <kmuto at debian.org>  Thu, 28 Jul 2005 11:35:27 +0900
 

Added: cupsys/trunk/debian/patches/47_pid.dpatch
==============================================================================
--- (empty file)
+++ cupsys/trunk/debian/patches/47_pid.dpatch	Mon Aug 15 15:05:39 2005
@@ -0,0 +1,72 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 47_pid.dpatch by Kenshi Muto <kmuto at debian.org>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: No description.
+
+ at DPATCH@
+diff -urNad --exclude=CVS --exclude=.svn ./scheduler/main.c /tmp/dpep-work.prfwXg/cupsys-1.1.23/scheduler/main.c
+--- ./scheduler/main.c	2005-08-15 15:00:06.000000000 +0000
++++ /tmp/dpep-work.prfwXg/cupsys-1.1.23/scheduler/main.c	2005-08-15 15:01:18.277965098 +0000
+@@ -67,7 +67,8 @@
+ static void	sigterm_handler(int sig);
+ static long	select_timeout(int fds);
+ static void	usage(void);
+-
++int write_pid(void);
++int remove_pid(void);
+ 
+ /*
+  * Local globals...
+@@ -423,6 +424,11 @@
+     setuid(User);
+   }
+ 
++  if (write_pid() == 0) {
++    LogMessage(L_ERROR, "Unable to write pid file");
++    return (1);
++  }
++
+  /*
+   * Start any pending print jobs...
+   */
+@@ -786,9 +792,39 @@
+   free(input);
+   free(output);
+ 
++  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("/var/run/cups/cupsd.pid", 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("/var/run/cups/cupsd.pid");
++}
++
+ 
+ /*
+  * 'cupsdClosePipe()' - Close a pipe as necessary.



More information about the Pkg-cups-devel mailing list