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

From David G. Johnston
Subject Re: BUG #18958: "pg_ctl start" allows subsequent CTRL-C key in cmd.exe to unexpectedly terminate cluster on Windows
Date
Msg-id CAKFQuwZZqJdJHdgDqnrcYTsVQWh7MpRR3qNLCqOgp_780TFo1A@mail.gmail.com
Whole thread Raw
In response to BUG #18958: "pg_ctl start" allows subsequent CTRL-C key in cmd.exe to unexpectedly terminate cluster on Windows  (PG Bug reporting form <noreply@postgresql.org>)
Responses Re: BUG #18958: "pg_ctl start" allows subsequent CTRL-C key in cmd.exe to unexpectedly terminate cluster on Windows
List pgsql-bugs
On Fri, Jun 13, 2025 at 6:34 AM PG Bug reporting form <noreply@postgresql.org> wrote:
The following bug has been logged on the website:

Bug reference:      18958
Logged by:          Seva Zaslavsky
Email address:      szaslavsky@mpcapitallp.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.

pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #18958: "pg_ctl start" allows subsequent CTRL-C key in cmd.exe to unexpectedly terminate cluster on Windows
Next
From: PG Bug reporting form
Date:
Subject: BUG #18959: Name collisions of expression indexes during parallel Index creations on a pratitioned table.