PostgreSQL in Windows console and Ctrl-C

From: Christian Ullrich <chris(at)chrullrich(dot)net>
To: pgsql-hackers(at)postgresql(dot)org
Subject: PostgreSQL in Windows console and Ctrl-C
Date: 2014-01-07 11:44:33
Message-ID: lagpal$86e$1@ger.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello all,

when pg_ctl start is used to run PostgreSQL in a console window on
Windows, it runs in the background (it is terminated by closing the
window, but that is probably inevitable). There is one problem, however:
The first Ctrl-C in that window, no matter in which situation, will
cause the background postmaster to exit. If you, say, ping something,
and press Ctrl-C to stop ping, you probably don't want the database to
go away, too.

The reason is that Windows delivers the Ctrl-C event to all processes
using that console, not just to the foreground one.

Here's a patch to fix that. "pg_ctl stop" still works, and it has no
effect when running as a service, so it should be safe. It starts the
postmaster in a new process group (similar to calling setpgrp() after
fork()) that does not receive Ctrl-C events from the console window.

--
Christian

Attachment Content-Type Size
pgsql-pgrp.diff text/plain 1.2 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2014-01-07 11:48:38 Re: generic pseudotype IO functions?
Previous Message Andres Freund 2014-01-07 11:30:41 Re: ERROR: missing chunk number 0 for toast value