aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2012-08-20 23:47:11 -0400
committerPeter Eisentraut <peter_e@gmx.net>2012-08-20 23:47:11 -0400
commitffdd5a0ee37c5ac38038aeff98328727e986d2da (patch)
tree986735e328d4d397d2842fbbbb6c13e24fca2347 /src
parent029722ac8e0d6b52872486b9d1907530fc8a0192 (diff)
downloadpostgresql-ffdd5a0ee37c5ac38038aeff98328727e986d2da.tar.gz
postgresql-ffdd5a0ee37c5ac38038aeff98328727e986d2da.zip
Remove external PID file on postmaster exit
Diffstat (limited to 'src')
-rw-r--r--src/backend/postmaster/postmaster.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index a4fb2a441e4..73520a6ca2f 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -329,6 +329,7 @@ static DNSServiceRef bonjour_sdref = NULL;
/*
* postmaster.c - function prototypes
*/
+static void unlink_external_pid_file(int status, Datum arg);
static void getInstallationPaths(const char *argv0);
static void checkDataDir(void);
static Port *ConnCreate(int serverFd);
@@ -1071,7 +1072,6 @@ PostmasterMain(int argc, char *argv[])
{
fprintf(fpidfile, "%d\n", MyProcPid);
fclose(fpidfile);
- /* Should we remove the pid file on postmaster exit? */
/* Make PID file world readable */
if (chmod(external_pid_file, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) != 0)
@@ -1081,6 +1081,8 @@ PostmasterMain(int argc, char *argv[])
else
write_stderr("%s: could not write external PID file \"%s\": %s\n",
progname, external_pid_file, strerror(errno));
+
+ on_proc_exit(unlink_external_pid_file, 0);
}
/*
@@ -1183,6 +1185,17 @@ PostmasterMain(int argc, char *argv[])
/*
+ * on_proc_exit callback to delete external_pid_file
+ */
+static void
+unlink_external_pid_file(int status, Datum arg)
+{
+ if (external_pid_file)
+ unlink(external_pid_file);
+}
+
+
+/*
* Compute and check the directory paths to files that are part of the
* installation (as deduced from the postgres executable's own location)
*/