From: Bruce Momjian Date: Thu, 13 Oct 2011 17:01:56 +0000 (-0400) Subject: Have pg_ctl return an exit status of 3 if the server is not running, to X-Git-Tag: REL9_2_BETA1~980 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=12ff9fa7715611d7df6a78447fce6cc5096cf335;p=postgresql Have pg_ctl return an exit status of 3 if the server is not running, to match the Linux Standard Base Core Specification 3.1. Aaron W. Swenson --- diff --git a/doc/src/sgml/ref/pg_ctl-ref.sgml b/doc/src/sgml/ref/pg_ctl-ref.sgml index 07836e718f..7dc170ee89 100644 --- a/doc/src/sgml/ref/pg_ctl-ref.sgml +++ b/doc/src/sgml/ref/pg_ctl-ref.sgml @@ -205,7 +205,8 @@ PostgreSQL documentation mode checks whether a server is running in the specified data directory. If it is, the PID and the command line options that were used to invoke it are - displayed. + displayed. If the server is not running, the process returns an + exit status of 3. diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index c9007eded9..8e9d2cec3d 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -1155,9 +1155,11 @@ do_status(void) pgpid_t pid; pid = get_pgpid(); - if (pid != 0) /* 0 means no pid file */ + /* Is there a pid file? */ + if (pid != 0) { - if (pid < 0) /* standalone backend */ + /* standalone backend? */ + if (pid < 0) { pid = -pid; if (postmaster_is_alive((pid_t) pid)) @@ -1168,7 +1170,7 @@ do_status(void) } } else - /* postmaster */ + /* must be a postmaster */ { if (postmaster_is_alive((pid_t) pid)) { @@ -1186,7 +1188,11 @@ do_status(void) } } printf(_("%s: no server running\n"), progname); - exit(1); + /* + * The Linux Standard Base Core Specification 3.1 says this should return '3' + * http://refspecs.freestandards.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-generic/iniscrptact.html + */ + exit(3); }