8000 Remove external PID file on postmaster exit · postgrespro/postgres_cluster@ffdd5a0 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ffdd5a0

Browse files
committed
Remove external PID file on postmaster exit
1 parent 029722a commit ffdd5a0

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/backend/postmaster/postmaster.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ static DNSServiceRef bonjour_sdref = NULL;
329329
/*
330330
* postmaster.c - function prototypes
331331
*/
332+
static void unlink_external_pid_file(int status, Datum arg);
332333
static void getInstallationPaths(const char *argv0);
333334
static void checkDataDir(void);
334335
static Port *ConnCreate(int serverFd);
@@ -1071,7 +1072,6 @@ PostmasterMain(int argc, char *argv[])
10711072
{
10721073
fprintf(fpidfile, "%d\n", MyProcPid);
10731074
fclose(fpidfile);
1074-
/* Should we remove the pid file on postmaster exit? */
10751075

10761076
/* Make PID file world readable */
10771077
if (chmod(external_pid_file, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) != 0)
@@ -1081,6 +1081,8 @@ PostmasterMain(int argc, char *argv[])
10811081
else
10821082
write_stderr("%s: could not write external PID file \"%s\": %s\n",
10831083
progname, external_pid_file, strerror(errno));
1084+
1085+
on_proc_exit(unlink_external_pid_file, 0);
10841086
}
10851087

10861088
/*
@@ -1182,6 +1184,17 @@ PostmasterMain(int argc, char *argv[])
11821184
}
11831185

11841186

1187+
/*
1188+
* on_proc_exit callback to delete external_pid_file
1189+
*/
1190+
static void
1191+
unlink_external_pid_file(int status, Datum arg)
1192+
{
1193+
if (external_pid_file)
1194+
unlink(external_pid_file);
1195+
}
1196+
1197+
11851198
/*
11861199
* Compute and check the directory paths to files that are part of the
11871200
* installation (as deduced from the postgres executable's own location)

0 commit comments

Comments
 (0)
0