Can we have a new SQL callable function to get Postmaster PID?

From: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Can we have a new SQL callable function to get Postmaster PID?
Date: 2021-02-03 06:12:17
Message-ID: CALj2ACW7YB7_w0eHgpxEFfc8gcm_pUkQBKBXHS8-orQ3HPnTfw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Can we have a new function, say pg_postgres_pid(), to return
postmaster PID similar to pg_backend_pid()? At times, it will be
difficult to use OS level commands to get the postmaster pid of a
backend to which it is connected. It's even worse if we have multiple
postgres server instances running on the same system. I'm not sure
whether it's safe to expose postmaster pid this way, but it will be
useful at least for debugging purposes on say Windows or other
non-Linux platforms where it's a bit difficult to get process id.
Users can also look at the postmaster.pid file to figure out what's
the current postmaster pid, if not using OS level commands, but having
a SQL callable function makes life easier.

The function can look like this:
Datum
pg_postgres_pid(PG_FUNCTION_ARGS)
{
PG_RETURN_INT32(PostmasterPid);
}

Thoughts?

With Regards,
Bharath Rupireddy.
EnterpriseDB: http://www.enterprisedb.com

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2021-02-03 06:37:39 Re: Allow CLUSTER, VACUUM FULL and REINDEX to change tablespace on the fly
Previous Message Bharath Rupireddy 2021-02-03 05:15:38 Re: Support ALTER SUBSCRIPTION ... ADD/DROP PUBLICATION ... syntax