summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBranden Robinson <branden@debian.org>2009-07-17 23:07:39 -0700
committerAlan Coopersmith <alan.coopersmith@sun.com>2009-07-17 23:07:39 -0700
commit2f5bd6ea016a6405208c91c976a16a672cc04184 (patch)
tree03b15373949710ce35e5576e7aa2de91fbb77174
parentec3152fbba9ee39bbb069913e76e9d165001f98a (diff)
Add RemovePid() function, and register it with atexit()
Debian bug#213076 Forward-ported by David Nusinow, Eugene Konev and Julien Cristau.
-rw-r--r--dm.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/dm.c b/dm.c
index 427de18..655380e 100644
--- a/dm.c
+++ b/dm.c
@@ -104,6 +104,7 @@ static SIGVAL ChildNotify (int n);
#endif
static int StorePid (void);
+static void RemovePid (void);
static pid_t parent_pid = -1; /* PID of parent xdm process */
@@ -159,6 +160,9 @@ main (int argc, char **argv)
LogInfo ("Starting\n");
+ if (atexit (RemovePid))
+ LogError ("could not register RemovePid() with atexit()\n");
+
if (nofork_session == 0) {
/* Clean up any old Authorization files */
/* AUD: all good? */
@@ -913,6 +917,19 @@ StorePid (void)
return 0;
}
+/*
+ * Remove process ID file. This function is registered with atexit().
+ */
+static void
+RemovePid (void)
+{
+ Debug ("unlinking process ID file %s\n", pidFile);
+ if (unlink (pidFile))
+ if (errno != ENOENT)
+ LogError ("cannot remove process ID file %s: %s\n", pidFile,
+ _SysErrorMsg (errno));
+}
+
#if 0
void
UnlockPidFile (void)