Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
d534b9ee
Commit
d534b9ee
authored
May 31, 2004
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Have pg_ctl print pid and error on signal failure, per suggestion from Tom.
parent
cbfa4092
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
28 deletions
+32
-28
src/bin/pg_ctl/pg_ctl.c
src/bin/pg_ctl/pg_ctl.c
+32
-28
No files found.
src/bin/pg_ctl/pg_ctl.c
View file @
d534b9ee
...
...
@@ -4,7 +4,7 @@
*
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.
1 2004/05/27 03:37:55
momjian Exp $
* $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.
2 2004/05/31 17:57:31
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -59,7 +59,6 @@ static int wait_seconds = 60;
static
bool
silence_echo
=
false
;
static
ShutdownMode
shutdown_mode
=
SMART_MODE
;
static
int
sig
=
SIGTERM
;
/* default */
static
int
killproc
;
static
CtlCommand
ctl_command
=
NO_COMMAND
;
static
char
*
pg_data_opts
=
NULL
;
static
char
*
pg_data
=
NULL
;
...
...
@@ -80,8 +79,8 @@ static void do_stop(void);
static
void
do_restart
(
void
);
static
void
do_reload
(
void
);
static
void
do_status
(
void
);
static
void
do_kill
(
vo
id
);
static
long
get_pgpid
(
void
);
static
void
do_kill
(
pid_t
p
id
);
static
pid_t
get_pgpid
(
void
);
static
char
**
readfile
(
char
*
path
);
static
int
start_postmaster
(
void
);
static
bool
test_postmaster_connection
(
void
);
...
...
@@ -127,11 +126,11 @@ xstrdup(const char *s)
static
long
static
pid_t
get_pgpid
(
void
)
{
FILE
*
pidf
;
long
pid
;
pid_t
pid
;
pidf
=
fopen
(
pid_file
,
"r"
);
if
(
pidf
==
NULL
)
...
...
@@ -145,7 +144,7 @@ get_pgpid(void)
exit
(
1
);
}
}
fscanf
(
pidf
,
"%
ld
"
,
&
pid
);
fscanf
(
pidf
,
"%
u
"
,
&
pid
);
fclose
(
pidf
);
return
pid
;
}
...
...
@@ -324,8 +323,8 @@ test_postmaster_connection(void)
static
void
do_start
(
void
)
{
long
pid
;
long
old_pid
=
0
;
pid_t
pid
;
pid_t
old_pid
=
0
;
char
*
optline
=
NULL
;
if
(
ctl_command
!=
RESTART_COMMAND
)
...
...
@@ -458,7 +457,7 @@ static void
do_stop
(
void
)
{
int
cnt
;
long
pid
;
pid_t
pid
;
pid
=
get_pgpid
();
...
...
@@ -473,14 +472,15 @@ do_stop(void)
pid
=
-
pid
;
fprintf
(
stderr
,
_
(
"%s: cannot stop postmaster; "
"postgres is running (PID: %
ld
)
\n
"
),
"postgres is running (PID: %
u
)
\n
"
),
progname
,
pid
);
exit
(
1
);
}
if
(
kill
(
(
pid_t
)
pid
,
sig
)
!=
0
)
if
(
kill
(
pid
,
sig
)
!=
0
)
{
fprintf
(
stderr
,
_
(
"stop signal failed
\n
"
));
fprintf
(
stderr
,
_
(
"stop signal failed (PID: %u): %s
\n
"
),
pid
,
strerror
(
errno
));
exit
(
1
);
}
...
...
@@ -537,7 +537,7 @@ static void
do_restart
(
void
)
{
int
cnt
;
long
pid
;
pid_t
pid
;
pid
=
get_pgpid
();
...
...
@@ -553,15 +553,16 @@ do_restart(void)
pid
=
-
pid
;
fprintf
(
stderr
,
_
(
"%s: cannot restart postmaster; "
"postgres is running (PID: %
ld
)
\n
"
),
"postgres is running (PID: %
u
)
\n
"
),
progname
,
pid
);
fprintf
(
stderr
,
_
(
"Please terminate postgres and try again.
\n
"
));
exit
(
1
);
}
if
(
kill
(
(
pid_t
)
pid
,
sig
)
!=
0
)
if
(
kill
(
pid
,
sig
)
!=
0
)
{
fprintf
(
stderr
,
_
(
"stop signal failed
\n
"
));
fprintf
(
stderr
,
_
(
"stop signal failed (PID: %u): %s
\n
"
),
pid
,
strerror
(
errno
));
exit
(
1
);
}
...
...
@@ -608,7 +609,7 @@ do_restart(void)
static
void
do_reload
(
void
)
{
long
pid
;
pid_t
pid
;
pid
=
get_pgpid
();
if
(
pid
==
0
)
/* no pid file */
...
...
@@ -622,15 +623,16 @@ do_reload(void)
pid
=
-
pid
;
fprintf
(
stderr
,
_
(
"%s: cannot reload postmaster; "
"postgres is running (PID: %
ld
)
\n
"
),
"postgres is running (PID: %
u
)
\n
"
),
progname
,
pid
);
fprintf
(
stderr
,
_
(
"Please terminate postgres and try again.
\n
"
));
exit
(
1
);
}
if
(
kill
(
(
pid_t
)
pid
,
sig
)
!=
0
)
if
(
kill
(
pid
,
sig
)
!=
0
)
{
fprintf
(
stderr
,
_
(
"reload signal failed
\n
"
));
fprintf
(
stderr
,
_
(
"reload signal failed (PID: %u): %s
\n
"
),
pid
,
strerror
(
errno
));
exit
(
1
);
}
...
...
@@ -645,7 +647,7 @@ do_reload(void)
static
void
do_status
(
void
)
{
long
pid
;
pid_t
pid
;
pid
=
get_pgpid
();
if
(
pid
==
0
)
/* no pid file */
...
...
@@ -656,13 +658,13 @@ do_status(void)
else
if
(
pid
<
0
)
/* standalone backend */
{
pid
=
-
pid
;
fprintf
(
stdout
,
_
(
"%s: a standalone backend
\"
postgres
\"
is running (PID: %
ld
)
\n
"
),
progname
,
pid
);
fprintf
(
stdout
,
_
(
"%s: a standalone backend
\"
postgres
\"
is running (PID: %
u
)
\n
"
),
progname
,
pid
);
}
else
/* postmaster */
{
char
**
optlines
;
fprintf
(
stdout
,
_
(
"%s: postmaster is running (PID: %
ld
)
\n
"
),
progname
,
pid
);
fprintf
(
stdout
,
_
(
"%s: postmaster is running (PID: %
u
)
\n
"
),
progname
,
pid
);
optlines
=
readfile
(
postopts_file
);
if
(
optlines
!=
NULL
)
...
...
@@ -674,11 +676,12 @@ do_status(void)
static
void
do_kill
(
vo
id
)
do_kill
(
pid_t
p
id
)
{
if
(
kill
(
killproc
,
sig
)
!=
0
)
if
(
kill
(
pid
,
sig
)
!=
0
)
{
fprintf
(
stderr
,
_
(
"signal %d failed
\n
"
),
sig
);
fprintf
(
stderr
,
_
(
"signal %d failed (PID: %u): %s
\n
"
),
sig
,
pid
,
strerror
(
errno
));
exit
(
1
);
}
}
...
...
@@ -810,6 +813,7 @@ main(int argc, char **argv)
int
option_index
;
int
c
;
int
killproc
=
0
;
#ifdef WIN32
setvbuf
(
stderr
,
NULL
,
_IONBF
,
0
);
...
...
@@ -1005,7 +1009,7 @@ main(int argc, char **argv)
do_reload
();
break
;
case
KILL_COMMAND
:
do_kill
();
do_kill
(
killproc
);
break
;
default:
break
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment