Thread: Dead code in ps_status.c

Dead code in ps_status.c

From
Thomas Munro
Date:
Hi,

Here's some archeology I did a while back, but was reminded to post
when I saw David's nearby performance improvements for ps_status.c.

 * there are no systems with HAVE_PS_STRINGS (ancient BSD)
 * setproctitle_fast() is in all live FreeBSD releases
 * setproctitle() is in all other BSDs
 * PostgreSQL can't run on GNU/Hurd apparently, for lack of shared
sempahores, so who would even know if that works?
 * IRIX is rusting in peace
 * there are no other NeXT-derived systems (NeXTSTEP and OPENSTEP are departed)

Therefore I think it is safe to drop the PS_USE_PS_STRING and
PS_USE_CHANGE_ARGV code branches, remove a bunch of outdated comments
and macro tests, and prune the defunct configure/meson probe.

I guess (defined(sun) && !defined(BSD)) || defined(__svr5__) could be
changed to just defined(sun) (surely there are no other living
SysV-derived systems, and I think non-BSD Sun probably meant "Solaris
but not SunOS"), but I don't know so I didn't touch that.

I think the history here is that the ancient BSD sendmail code
(conf.c) had all this stuff for BSD and SVR5 systems, but then its
setproctitle() function actually moved into the OS so that the
underlying PS_STRINGS stuff wouldn't have to be stable, and indeed it
was not.

Attachment

Re: Dead code in ps_status.c

From
Tom Lane
Date:
Thomas Munro <thomas.munro@gmail.com> writes:
> Therefore I think it is safe to drop the PS_USE_PS_STRING and
> PS_USE_CHANGE_ARGV code branches, remove a bunch of outdated comments
> and macro tests, and prune the defunct configure/meson probe.

Seems reasonable.  Patch passes an eyeball check.

> I guess (defined(sun) && !defined(BSD)) || defined(__svr5__) could be
> changed to just defined(sun) (surely there are no other living
> SysV-derived systems, and I think non-BSD Sun probably meant "Solaris
> but not SunOS"), but I don't know so I didn't touch that.

Hm, is "defined(sun)" true on any live systems at all?

            regards, tom lane



Re: Dead code in ps_status.c

From
Thomas Munro
Date:
On Thu, Feb 16, 2023 at 6:34 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Thomas Munro <thomas.munro@gmail.com> writes:
> > Therefore I think it is safe to drop the PS_USE_PS_STRING and
> > PS_USE_CHANGE_ARGV code branches, remove a bunch of outdated comments
> > and macro tests, and prune the defunct configure/meson probe.
>
> Seems reasonable.  Patch passes an eyeball check.

Thanks for looking.

> > I guess (defined(sun) && !defined(BSD)) || defined(__svr5__) could be
> > changed to just defined(sun) (surely there are no other living
> > SysV-derived systems, and I think non-BSD Sun probably meant "Solaris
> > but not SunOS"), but I don't know so I didn't touch that.
>
> Hm, is "defined(sun)" true on any live systems at all?

My GCC compile farm account seems to have expired, or something, so I
couldn't check on wrasse's host (though whether wrasse is "live" is
debatable: Solaris 11.3 has reached EOL, it's just that the CPU is too
old to be upgraded, so it's not testing a real OS that anyone would
actually run PostgreSQL on).  But from some googling[1], I think
__sun, __sun__ and sun should all be defined.

Ohh, but __svr5__ should not be.  Solaris boxes define __svr4__, I was
confused by the two fives.  __svr5__ was SCO/Unixware, another dead
OS[1], so I think we can just remove that one too.  So, yeah, I think
we should replace (defined(sun) && !defined(BSD)) || defined(__svr5__)
with defined(__sun).  (Hmph.  We have all of __sun__, __sun and sun in
the tree.)

[1] https://stackoverflow.com/questions/16618604/solaris-and-preprocessor-macros
[2] https://en.wikipedia.org/wiki/UNIX_System_V#SVR5_/_UnixWare_7



Re: Dead code in ps_status.c

From
Tom Lane
Date:
Thomas Munro <thomas.munro@gmail.com> writes:
> On Thu, Feb 16, 2023 at 6:34 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Hm, is "defined(sun)" true on any live systems at all?

> My GCC compile farm account seems to have expired, or something, so I
> couldn't check on wrasse's host (though whether wrasse is "live" is
> debatable: Solaris 11.3 has reached EOL, it's just that the CPU is too
> old to be upgraded, so it's not testing a real OS that anyone would
> actually run PostgreSQL on).  But from some googling[1], I think
> __sun, __sun__ and sun should all be defined.

My account still works, and what I see on wrasse's host is

tgl@gcc-solaris11:~$ gcc -x c /dev/null -dM -E | grep -i svr
#define __SVR4 1
#define __svr4__ 1
tgl@gcc-solaris11:~$ gcc -x c /dev/null -dM -E | grep -i sun
#define __sun 1
#define sun 1
#define __sun__ 1

I don't know a way to get the list of predefined macros out of the
compiler wrasse is actually using (/opt/developerstudio12.6/bin/cc),
but doing some experiments with #ifdef confirmed that it defines
__sun, __sun__, and __svr4__, but not __svr5__.

            regards, tom lane



Re: Dead code in ps_status.c

From
Thomas Munro
Date:
On Fri, Feb 17, 2023 at 3:38 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> My account still works, and what I see on wrasse's host is
>
> tgl@gcc-solaris11:~$ gcc -x c /dev/null -dM -E | grep -i svr
> #define __SVR4 1
> #define __svr4__ 1
> tgl@gcc-solaris11:~$ gcc -x c /dev/null -dM -E | grep -i sun
> #define __sun 1
> #define sun 1
> #define __sun__ 1
>
> I don't know a way to get the list of predefined macros out of the
> compiler wrasse is actually using (/opt/developerstudio12.6/bin/cc),
> but doing some experiments with #ifdef confirmed that it defines
> __sun, __sun__, and __svr4__, but not __svr5__.

Thanks.  I went with __sun, because a random man page google found me
for Sun "cc" mentioned that but not __sun__.  Pushed.

http://www.polarhome.com/service/man/?qf=cc&tf=2&of=Solaris&sf=1



Re: Dead code in ps_status.c

From
Thomas Munro
Date:
On Fri, Feb 17, 2023 at 3:38 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Thomas Munro <thomas.munro@gmail.com> writes:
> > On Thu, Feb 16, 2023 at 6:34 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> > My GCC compile farm account seems to have expired, or something, so I
> > couldn't check on wrasse's host (though whether wrasse is "live" is
> > debatable: Solaris 11.3 has reached EOL, it's just that the CPU is too
> > old to be upgraded, so it's not testing a real OS that anyone would
> > actually run PostgreSQL on).  ...

> My account still works, and what I see on wrasse's host is

Just in case it helps someone else who finds themselves locked out of
that, I noticed that I can still connect from my machine with OpenSSH
8.8p1, but not from another dev box which was upgraded to OpenSSH
9.2p1.  For reasons I didn't look into, the latter doesn't like
exchanging 1s and 0s with "Sun_SSH_2.4" (something Oracle has
apparently now abandoned in favour of stock OpenSSH, but that machine
is stuck in time).



Re: Dead code in ps_status.c

From
Andres Freund
Date:
Hi,

On 2023-03-11 16:59:46 +1300, Thomas Munro wrote:
> On Fri, Feb 17, 2023 at 3:38 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> > Thomas Munro <thomas.munro@gmail.com> writes:
> > > On Thu, Feb 16, 2023 at 6:34 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> > > My GCC compile farm account seems to have expired, or something, so I
> > > couldn't check on wrasse's host (though whether wrasse is "live" is
> > > debatable: Solaris 11.3 has reached EOL, it's just that the CPU is too
> > > old to be upgraded, so it's not testing a real OS that anyone would
> > > actually run PostgreSQL on).  ...
>
> > My account still works, and what I see on wrasse's host is
>
> Just in case it helps someone else who finds themselves locked out of
> that, I noticed that I can still connect from my machine with OpenSSH
> 8.8p1, but not from another dev box which was upgraded to OpenSSH
> 9.2p1.  For reasons I didn't look into, the latter doesn't like
> exchanging 1s and 0s with "Sun_SSH_2.4" (something Oracle has
> apparently now abandoned in favour of stock OpenSSH, but that machine
> is stuck in time).

It's the key types supported by the old ssh. I have the following in my
~/.ssh/config to work around that:

Host gcc210.fsffrance.org
    PubkeyAcceptedKeyTypes +ssh-rsa
    KexAlgorithms +diffie-hellman-group1-sha1
Host gcc211.fsffrance.org
    PubkeyAcceptedKeyTypes +ssh-rsa

Greetings,

Andres Freund