pg_ctl and port number detection

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org>
Subject: pg_ctl and port number detection
Date: 2010-12-18 18:22:07
Message-ID: 201012181822.oBIIM7810637@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

pg_ctl.c::test_postmaster_connection() has some fragile code that tries
to detect the server port number by looking in the pg_ctl -o string,
postgresql.conf, the PGPORT environment variable, and finally using the
default port number.

I think a simpler solution would be to look in postmaster.pid:

10231
/u/pgsql/data
5432001 45481984

pg_ctl already knows the data directory. If the file is missing, the
server is not running. If the file exists, the first number on the last
line, divided by 1000, is the port number. We can then use this port
number for libpq to check for connectivity.

Comments?

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

+ It's impossible for everything to be true. +

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jan Urbański 2010-12-18 18:33:00 Re: exceptions not present in plpy with Python 3
Previous Message Jan Urbański 2010-12-18 17:56:29 exceptions not present in plpy with Python 3