Re: BUG #18958: "pg_ctl start" allows subsequent CTRL-C key in cmd.exe to unexpectedly terminate cluster on Windows

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: szaslavsky(at)mpcapitallp(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18958: "pg_ctl start" allows subsequent CTRL-C key in cmd.exe to unexpectedly terminate cluster on Windows
Date: 2025-06-13 13:46:39
Message-ID: CAKFQuwZZqJdJHdgDqnrcYTsVQWh7MpRR3qNLCqOgp_780TFo1A@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Fri, Jun 13, 2025 at 6:34 AM PG Bug reporting form <
noreply(at)postgresql(dot)org> wrote:

> The following bug has been logged on the website:
>
> Bug reference: 18958
> Logged by: Seva Zaslavsky
> Email address: szaslavsky(at)mpcapitallp(dot)com
> PostgreSQL version: 17.5
> Operating system: Windows Server 2019
> Description:
>
> J:\Users\Public\PostgreSQL\data>"c:\Program
> Files\PostgreSQL\17.5\bin\pg_ctl" start -D
> "J:\Users\Public\PostgreSQL\data\5438" -o "-p 5438"
> waiting for server to start....2025-06-13 08:44:06.019 EDT [10020] [] LOG:
> redirecting log output to logging collector process
> 2025-06-13 08:44:06.019 EDT [10020] [] HINT: Future log output will appear
> in directory "pg_log".
> done
> server started
>
>
A bit surprising I suppose, but documented.

"""
start mode launches a new server. The server is started in the background,
and its standard input is attached to /dev/null (or nul on Windows). On
Unix-like systems, by default, the server's standard output and standard
error are sent to pg_ctl's standard output (not standard error). The
standard output of pg_ctl should then be redirected to a file or piped to
another process such as a log rotating program like rotatelogs; otherwise
postgres will write its output to the controlling terminal (from the
background) and will not leave the shell's process group. On Windows, by
default the server's standard output and standard error are sent to the
terminal. These default behaviors can be changed by using -l to append the
server's output to a log file. Use of either -l or output redirection is
recommended.
"""

Note the final sentence, neither of which was done here.

In short, while the server configuration stopped sending log data to
stdout/stderr due to the log_collector directive pg_ctl has no awareness of
that happening and so keeps itself attached to the process that launched it
so the operator can see those streams.

David J.

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message John Naylor 2025-06-13 14:03:16 Re: Invalid control file checksum with AVX-512 during initdb on a clang19 -O0 build
Previous Message PG Bug reporting form 2025-06-13 13:21:04 BUG #18958: "pg_ctl start" allows subsequent CTRL-C key in cmd.exe to unexpectedly terminate cluster on Windows