Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit169051a

Browse files
committed
Fix bugs regarding pid file.
1 parent1891f0e commit169051a

File tree

1 file changed

+30
-5
lines changed

1 file changed

+30
-5
lines changed

‎src/backend/postmaster/postmaster.c

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.129 1999/12/04 08:23:43 ishii Exp $
13+
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.130 1999/12/06 07:21:12 ishii Exp $
1414
*
1515
* NOTES
1616
*
@@ -250,6 +250,11 @@ static boolFatalError = false;
250250

251251
staticunsignedintrandom_seed=0;
252252

253+
/*
254+
* Path to pid file. Exitpostmaster() remember it to unlink the file.
255+
*/
256+
staticcharPidFile[MAXPGPATH];
257+
253258
externchar*optarg;
254259
externintoptind,
255260
opterr;
@@ -277,7 +282,8 @@ static long PostmasterRandom(void);
277282
staticvoidRandomSalt(char*salt);
278283
staticvoidSignalChildren(SIGNAL_ARGS);
279284
staticintCountChildren(void);
280-
285+
staticvoidUnlinkPidFile(void);
286+
staticvoidSetPidFname(char*datadir);
281287
staticintSetPidFile(pid_tpid,char*progname,intport,char*datadir,
282288
intassert,intnbuf,char*execfile,
283289
intdebuglvl,intnetserver,
@@ -748,6 +754,7 @@ pmdaemonize(char *extraoptions)
748754
}
749755
_exit(0);
750756
}
757+
751758
/* GH: If there's no setsid(), we hopefully don't need silent mode.
752759
* Until there's a better solution.
753760
*/
@@ -768,6 +775,12 @@ pmdaemonize(char *extraoptions)
768775
dup2(i,1);
769776
dup2(i,2);
770777
close(i);
778+
779+
/*
780+
* register clean up proc
781+
*/
782+
SetPidFname(DataDir);
783+
on_proc_exit(UnlinkPidFile,NULL);
771784
}
772785

773786
staticvoid
@@ -2165,13 +2178,25 @@ SSDataBase(bool startup)
21652178
return(pid);
21662179
}
21672180

2168-
staticcharPidFile[MAXPGPATH];
2169-
2181+
/*
2182+
* Remove the pid file. This function is called from proc_exit.
2183+
*/
21702184
staticvoidUnlinkPidFile(void)
21712185
{
21722186
unlink(PidFile);
21732187
}
21742188

2189+
/*
2190+
* Set path to the pid file
2191+
*/
2192+
staticvoidSetPidFname(char*datadir)
2193+
{
2194+
snprintf(PidFile,sizeof(PidFile),"%s/%s",datadir,PIDFNAME);
2195+
}
2196+
2197+
/*
2198+
* Create the pid file
2199+
*/
21752200
staticintSetPidFile(pid_tpid,char*progname,intport,char*datadir,
21762201
intassert,intnbuf,char*execfile,
21772202
intdebuglvl,intnetserver,
@@ -2192,7 +2217,7 @@ static int SetPidFile(pid_t pid, char *progname, int port, char *datadir,
21922217
/*
21932218
* Creating pid file
21942219
*/
2195-
snprintf(PidFile,sizeof(PidFile),"%s/%s",datadir,PIDFNAME);
2220+
SetPidFname(datadir);
21962221
fd=open(PidFile,O_RDWR |O_CREAT |O_EXCL,0600);
21972222
if (fd<0) {
21982223
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp