2568000
diff -up cups-1.7.0/notifier/dbus.c.dbus-notifier cups-1.7.0/notifier/dbus.c
2568000
--- cups-1.7.0/notifier/dbus.c.dbus-notifier	2013-11-14 18:10:31.745121435 +0000
2568000
+++ cups-1.7.0/notifier/dbus.c	2013-11-14 18:10:53.997227718 +0000
c994ebe
@@ -4,7 +4,7 @@
c994ebe
  *   D-Bus notifier for CUPS.
c994ebe
  *
2568000
  *   Copyright 2008-2012 by Apple Inc.
c994ebe
- *   Copyright (C) 2011 Red Hat, Inc.
c994ebe
+ *   Copyright (C) 2011, 2013 Red Hat, Inc.
c994ebe
  *   Copyright (C) 2007 Tim Waugh <twaugh@redhat.com>
c994ebe
  *   Copyright 1997-2005 by Easy Software Products.
c994ebe
  *
7e2a581
@@ -157,9 +157,16 @@ enum
c994ebe
 
c994ebe
 
c994ebe
 /*
c994ebe
+ * Global variables...
c994ebe
+ */
c994ebe
+
c994ebe
+static char		lock_filename[1024];	/* Lock filename */
c994ebe
+
c994ebe
+/*
c994ebe
  * Local functions...
c994ebe
  */
c994ebe
 
c994ebe
+static void		release_lock(void);
c994ebe
 static int		acquire_lock(int *fd, char *lockfile, size_t locksize);
c994ebe
 static const char	*validate_utf8(const char *str);
c994ebe
 
7e2a581
@@ -251,8 +258,6 @@ main(int  argc,				/* I - Number of comm
c994ebe
   DBusMessage		*message;	/* Message to send */
c994ebe
   DBusMessageIter	iter;		/* Iterator for message data */
c994ebe
   int			lock_fd = -1;	/* Lock file descriptor */
c994ebe
-  char			lock_filename[1024];
c994ebe
-					/* Lock filename */
c994ebe
 
c994ebe
 
c994ebe
  /*
2568000
@@ -653,7 +658,7 @@ main(int  argc,				/* I - Number of comm
c994ebe
   if (lock_fd >= 0)
c994ebe
   {
c994ebe
     close(lock_fd);
c994ebe
-    unlink(lock_filename);
c994ebe
+    release_lock();
c994ebe
   }
c994ebe
 
c994ebe
   return (0);
2568000
@@ -661,6 +666,26 @@ main(int  argc,				/* I - Number of comm
c994ebe
 
c994ebe
 
c994ebe
 /*
c994ebe
+ * 'release_lock()' - Release the singleton lock.
c994ebe
+ */
c994ebe
+
c994ebe
+static void
c994ebe
+release_lock(void)
c994ebe
+{
c994ebe
+  unlink(lock_filename);
c994ebe
+}
c994ebe
+
c994ebe
+
c994ebe
+/*
c994ebe
+ * 'handle_sigterm()' - Handle SIGTERM signal.
c994ebe
+ */
c994ebe
+static void
c994ebe
+handle_sigterm(int signum)
c994ebe
+{
c994ebe
+  release_lock();
c994ebe
+}
c994ebe
+
c994ebe
+/*
c994ebe
  * 'acquire_lock()' - Acquire a lock so we only have a single notifier running.
c994ebe
  */
c994ebe
 
2568000
@@ -669,7 +694,8 @@ acquire_lock(int    *fd,		/* O - Lock fi
c994ebe
              char   *lockfile,		/* I - Lock filename buffer */
c994ebe
 	     size_t locksize)		/* I - Size of filename buffer */
c994ebe
 {
c994ebe
-  const char	*tmpdir;		/* Temporary directory */
c994ebe
+  const char		*tmpdir;	/* Temporary directory */
c994ebe
+  struct sigaction	action;		/* POSIX sigaction data */
c994ebe
 
c994ebe
 
c994ebe
  /*
2568000
@@ -687,8 +713,16 @@ acquire_lock(int    *fd,		/* O - Lock fi
c994ebe
 
c994ebe
   if ((*fd = open(lockfile, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR)) < 0)
c994ebe
     return (-1);
c994ebe
-  else
c994ebe
-    return (0);
c994ebe
+
c994ebe
+ /*
c994ebe
+  * Set a SIGTERM handler to make sure we release the lock if the
c994ebe
+  * scheduler decides to stop us.
c994ebe
+  */
c994ebe
+  memset(&action, 0, sizeof(action));
c994ebe
+  action.sa_handler = handle_sigterm;
c994ebe
+  sigaction(SIGTERM, &action, NULL);
c994ebe
+
c994ebe
+  return (0);
c994ebe
 }
7e2a581
 #else /* !HAVE_DBUS */
7e2a581
 int