Zdenek Kotala <Zdenek.Kotala@Sun.COM> writes:
> 1) Is there still some reason have negative value in postmaster.pid?
Just to distinguish postmasters from standalone backends in the error
messages. I think that's still useful.
> 2) Why 100? What race condition should happen? This piece of code looks
> like kind of magic.
There are at least two race cases identified in the comments in the
loop.
> 3) Why pid checking and cleanup is in postgres? I think it is role of
> pg_ctl or init scripts.
Let's see, instead of one place in the postgres code we should do it in
N places in different init scripts, and just trust to luck that a
particular installation is using an init script that knows to do that?
I don't think so. Besides, how is the init script going to remove it
again? It won't still be running when the postmaster exits.
> 4) The following condition is buggy, because atoi function does not have
> defined result if parameter is not valid number.
> if (other_pid <= 0)
It's not actually trying to validate the syntax of the lock file, only
to make certain it doesn't trigger any unexpected behavior in kill().
I don't think I've yet seen any reports that suggest that more syntax
checking of the lock file would be a useful activity.
regards, tom lane