On 2019-Jul-23, Tom Lane wrote:
> Kyotaro Horiguchi <horikyota.ntt@gmail.com> writes:
> > My investigation convinced me that there is no way for a process
> > to detect wheter it is running as a service (except the process
> > directly called from system (aka entry function)).
Maybe we can try calling pgwin32_is_service()?
> But I will say that in my experience, behavioral differences between
> Postgres started manually and Postgres started as a daemon are bad.
> So I think going out of our way to make the cases behave differently
> on Windows is probably not a good plan.
We already have such a difference in Windows -- elog.c uses it
extensively to use the eventlog to print if a service, console print if
not.
Given this thread's OP, ISTM failing to do likewise for this case makes
debugging problems difficult for no good reason.
--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services