Remove external PID file on postmaster exit
This commit is contained in:
parent
029722ac8e
commit
ffdd5a0ee3
@ -329,6 +329,7 @@ static DNSServiceRef bonjour_sdref = NULL;
|
|||||||
/*
|
/*
|
||||||
* postmaster.c - function prototypes
|
* postmaster.c - function prototypes
|
||||||
*/
|
*/
|
||||||
|
static void unlink_external_pid_file(int status, Datum arg);
|
||||||
static void getInstallationPaths(const char *argv0);
|
static void getInstallationPaths(const char *argv0);
|
||||||
static void checkDataDir(void);
|
static void checkDataDir(void);
|
||||||
static Port *ConnCreate(int serverFd);
|
static Port *ConnCreate(int serverFd);
|
||||||
@ -1071,7 +1072,6 @@ PostmasterMain(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
fprintf(fpidfile, "%d\n", MyProcPid);
|
fprintf(fpidfile, "%d\n", MyProcPid);
|
||||||
fclose(fpidfile);
|
fclose(fpidfile);
|
||||||
/* Should we remove the pid file on postmaster exit? */
|
|
||||||
|
|
||||||
/* Make PID file world readable */
|
/* Make PID file world readable */
|
||||||
if (chmod(external_pid_file, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) != 0)
|
if (chmod(external_pid_file, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) != 0)
|
||||||
@ -1081,6 +1081,8 @@ PostmasterMain(int argc, char *argv[])
|
|||||||
else
|
else
|
||||||
write_stderr("%s: could not write external PID file \"%s\": %s\n",
|
write_stderr("%s: could not write external PID file \"%s\": %s\n",
|
||||||
progname, external_pid_file, strerror(errno));
|
progname, external_pid_file, strerror(errno));
|
||||||
|
|
||||||
|
on_proc_exit(unlink_external_pid_file, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1182,6 +1184,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
|
* Compute and check the directory paths to files that are part of the
|
||||||
* installation (as deduced from the postgres executable's own location)
|
* installation (as deduced from the postgres executable's own location)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user