Noah Misch <noah(at)leadboat(dot)com> writes:
> I'm thinking the server should manage this; during startup, create
> $stats_temp_directory/PostgreSQL.$postmaster_pid and store each stats file
> therein.
+1
> Just before creating that directory, scan $stats_temp_directory and
> delete subdirectories that no longer correspond to live PIDs.
Hm, seems potentially racy, if multiple postmasters are starting
at the same time. The only one you can be *sure* is dead is one
with your own PID.
regards, tom lane