Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
d9f61cfa
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d9f61cfa
编写于
12月 04, 1999
作者:
T
Tatsuo Ishii
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Unlink the pid file if it's bogus (no associated process exists)
上级
e958a305
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
113 addition
and
22 deletion
+113
-22
src/backend/postmaster/postmaster.c
src/backend/postmaster/postmaster.c
+113
-22
未找到文件。
src/backend/postmaster/postmaster.c
浏览文件 @
d9f61cfa
...
...
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.12
8 1999/12/03 06:26:34
ishii Exp $
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.12
9 1999/12/04 08:23:43
ishii Exp $
*
* NOTES
*
...
...
@@ -257,7 +257,7 @@ extern int optind,
/*
* postmaster.c - function prototypes
*/
static
void
pmdaemonize
(
void
);
static
void
pmdaemonize
(
char
*
extraoptions
);
static
Port
*
ConnCreate
(
int
serverFd
);
static
void
ConnFree
(
Port
*
port
);
static
void
reset_shared
(
unsigned
short
port
);
...
...
@@ -645,13 +645,13 @@ PostmasterMain(int argc, char *argv[])
BackendList
=
DLNewList
();
PortList
=
DLNewList
();
if
(
silentflag
)
pmdaemonize
();
/*
* create pid file. if the file has already existed, exits.
*/
if
(
SetPidFile
(
if
(
silentflag
)
{
pmdaemonize
(
original_extraoptions
);
}
else
{
/*
* create pid file. if the file has already existed, exits.
*/
if
(
SetPidFile
(
getpid
(),
/* postmaster process id */
progname
,
/* postmaster executable file */
PostPortName
,
/* port number */
...
...
@@ -670,9 +670,10 @@ PostmasterMain(int argc, char *argv[])
SendStop
,
/* -s: send SIGSTOP */
original_extraoptions
/* options for backend */
)
)
{
ExitPostmaster
(
1
);
return
0
;
)
{
ExitPostmaster
(
1
);
return
0
;
/* not reached */
}
}
/*
...
...
@@ -703,12 +704,50 @@ PostmasterMain(int argc, char *argv[])
}
static
void
pmdaemonize
(
void
)
pmdaemonize
(
char
*
extraoptions
)
{
int
i
;
pid_t
pid
;
if
(
fork
())
pid
=
fork
();
if
(
pid
==
-
1
)
{
perror
(
"Failed to fork postmaster"
);
ExitPostmaster
(
1
);
return
;
/* not reached */
}
else
if
(
pid
)
{
/* parent */
/*
* create pid file. if the file has already existed, exits.
*/
if
(
SetPidFile
(
pid
,
/* postmaster process id */
progname
,
/* postmaster executable file */
PostPortName
,
/* port number */
DataDir
,
/* PGDATA */
assert_enabled
,
/* whether -A is specified or not */
NBuffers
,
/* -B: number of shared buffers */
Execfile
,
/* -b: postgres executable file */
DebugLvl
,
/* -d: debug level */
NetServer
,
/* -i: accept connection from INET */
#ifdef USE_SSL
SecureNetServer
,
/* -l: use SSL */
#endif
MaxBackends
,
/* -N: max number of backends */
Reinit
,
/* -n: reinit shared mem after failure */
1
,
/* -S: detach tty */
SendStop
,
/* -s: send SIGSTOP */
extraoptions
/* options for backend */
)
)
{
/*
* Failed to create pid file. kill the child and
* exit now.
*/
kill
(
pid
,
SIGTERM
);
ExitPostmaster
(
1
);
return
;
/* not reached */
}
_exit
(
0
);
}
/* GH: If there's no setsid(), we hopefully don't need silent mode.
* Until there's a better solution.
*/
...
...
@@ -2145,22 +2184,74 @@ static int SetPidFile(pid_t pid, char *progname, int port, char *datadir,
int
fd
;
char
optsfile
[
MAXPGPATH
];
char
pidstr
[
32
];
int
len
;
pid_t
post_pid
;
char
opts
[
1024
];
char
buf
[
1024
];
/*
* Creating pid file
*/
s
printf
(
PidFile
,
"%s/%s"
,
datadir
,
PIDFNAME
);
s
nprintf
(
PidFile
,
sizeof
(
PidFile
),
"%s/%s"
,
datadir
,
PIDFNAME
);
fd
=
open
(
PidFile
,
O_RDWR
|
O_CREAT
|
O_EXCL
,
0600
);
if
(
fd
<
0
)
{
fprintf
(
stderr
,
"Can't create pidfile: %s
\n
"
,
PidFile
);
fprintf
(
stderr
,
"Is another postmaser running?
\n
"
);
return
(
-
1
);
/*
* Couldn't create the pid file. Probably
* it already exists. Read the file to see if the process
* actually exists
*/
fd
=
open
(
PidFile
,
O_RDONLY
,
0600
);
if
(
fd
<
0
)
{
fprintf
(
stderr
,
"Can't create/read pid file: %s
\n
"
,
PidFile
);
fprintf
(
stderr
,
"Please check the permission and try again.
\n
"
);
return
(
-
1
);
}
if
((
len
=
read
(
fd
,
pidstr
,
sizeof
(
pidstr
)
-
1
))
<
0
)
{
fprintf
(
stderr
,
"Can't create/read pid file: %s
\n
"
,
PidFile
);
fprintf
(
stderr
,
"Please check the permission and try again.
\n
"
);
close
(
fd
);
return
(
-
1
);
}
close
(
fd
);
/*
* Check to see if the process actually exists
*/
pidstr
[
len
]
=
'\0'
;
post_pid
=
(
pid_t
)
atoi
(
pidstr
);
if
(
post_pid
==
0
||
(
post_pid
>
0
&&
kill
(
post_pid
,
0
)
<
0
))
{
/*
* No, the process did not exist. Unlink
* the file and try to create it
*/
if
(
unlink
(
PidFile
)
<
0
)
{
fprintf
(
stderr
,
"Can't remove pidfile: %s
\n
"
,
PidFile
);
fprintf
(
stderr
,
"The file seems accidently left, but I couldn't remove it.
\n
"
);
fprintf
(
stderr
,
"Please remove the file by hand and try again.
\n
"
);
return
(
-
1
);
}
fd
=
open
(
PidFile
,
O_RDWR
|
O_CREAT
|
O_EXCL
,
0600
);
if
(
fd
<
0
)
{
fprintf
(
stderr
,
"Can't create pidfile: %s
\n
"
,
PidFile
);
fprintf
(
stderr
,
"Please check the permission and try again.
\n
"
);
return
(
-
1
);
}
}
else
{
/*
* Another postmaster is running
*/
fprintf
(
stderr
,
"Can't create pidfile: %s
\n
"
,
PidFile
);
fprintf
(
stderr
,
"Is another postmaser (pid: %s) running?
\n
"
,
pidstr
);
return
(
-
1
);
}
}
sprintf
(
pidstr
,
"%d"
,
pid
);
if
(
write
(
fd
,
pidstr
,
strlen
(
pidstr
))
!=
strlen
(
pidstr
))
{
fprintf
(
stderr
,
"Write to pid file failed
\n
"
);
fprintf
(
stderr
,
"Please check the permission and try again.
\n
"
);
close
(
fd
);
unlink
(
PidFile
);
return
(
-
1
);
...
...
@@ -2170,20 +2261,20 @@ static int SetPidFile(pid_t pid, char *progname, int port, char *datadir,
/*
* Creating opts file
*/
s
printf
(
optsfile
,
"%s/%s"
,
datadir
,
OPTSFNAME
);
s
nprintf
(
optsfile
,
sizeof
(
optsfile
),
"%s/%s"
,
datadir
,
OPTSFNAME
);
fd
=
open
(
optsfile
,
O_RDWR
|
O_TRUNC
|
O_CREAT
,
0600
);
if
(
fd
<
0
)
{
fprintf
(
stderr
,
"Can't create optsfile:%s"
,
optsfile
);
unlink
(
PidFile
);
return
(
-
1
);
}
s
printf
(
opts
,
"%s
\n
-p %d
\n
-D %s
\n
"
,
progname
,
port
,
datadir
);
s
nprintf
(
opts
,
sizeof
(
opts
)
,
"%s
\n
-p %d
\n
-D %s
\n
"
,
progname
,
port
,
datadir
);
if
(
assert
)
{
sprintf
(
buf
,
"-A %d
\n
"
,
assert
);
strcat
(
opts
,
buf
);
}
s
printf
(
buf
,
"-B %d
\n
-b %s
\n
"
,
nbuf
,
execfile
);
s
nprintf
(
buf
,
sizeof
(
buf
)
,
"-B %d
\n
-b %s
\n
"
,
nbuf
,
execfile
);
strcat
(
opts
,
buf
);
if
(
debuglvl
)
{
...
...
@@ -2201,7 +2292,7 @@ static int SetPidFile(pid_t pid, char *progname, int port, char *datadir,
}
#endif
s
printf
(
buf
,
"-N %d
\n
"
,
maxbackends
);
s
nprintf
(
buf
,
sizeof
(
buf
)
,
"-N %d
\n
"
,
maxbackends
);
strcat
(
opts
,
buf
);
if
(
!
reinit
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录