Re: pg_ctl status with nonexistent data directory

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_ctl status with nonexistent data directory
Date: 2014-03-05 23:08:38
Message-ID: 20140305230838.GB20275@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Nov 4, 2013 at 11:31:30AM -0500, Robert Haas wrote:
> On Sat, Nov 2, 2013 at 3:32 PM, Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:
> > This doesn't seem right:
> >
> > $ pg_ctl -D /nowhere status
> > pg_ctl: no server running
> >
> > It does exit with status 3, so it's not all that broken, but I think the
> > error message could be more accurate.
>
> I doubt anyone will object if you feel the urge to fix it. I won't, anyway.

I have addressed this issue with the attached patch:

$ pg_ctl -D /lkjasdf status
pg_ctl: directory "/lkjasdf" does not exist
$ pg_ctl -D / status
pg_ctl: directory "/" is not a database cluster directory

One odd question is that pg_ctl status has this comment for reporting
the exit code for non-running servers:

printf(_("%s: no server running\n"), progname);

/*
* The Linux Standard Base Core Specification 3.1 says this should return
* '3'
* https://refspecs.linuxbase.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
*/
exit(3);

If they haven't passed us a data directory, we don't really know if the
server is running or not, so the patch just returns '1'.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ Everyone has their own god. +

Attachment Content-Type Size
pg_ctl.diff text/x-diff 1.5 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2014-03-05 23:15:49 Re: exit_horribly vs exit_nicely in pg_dump
Previous Message Tom Lane 2014-03-05 22:49:10 Re: [PATCH] Negative Transition Aggregate Functions (WIP)