Re: [Patch] Create a new session in postmaster by calling setsid()

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, Andres Freund <andres(at)anarazel(dot)de>, Paul Guo <pguo(at)pivotal(dot)io>, Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [Patch] Create a new session in postmaster by calling setsid()
Date: 2018-12-30 19:59:29
Message-ID: 48215103-75de-0500-a0d1-261757112400@iki.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 28/12/2018 22:13, Tom Lane wrote:
> Heikki Linnakangas <hlinnaka(at)iki(dot)fi> writes:
>> Another idea would be to call setsid() in pg_ctl, after forking
>> postmaster, like in Paul's original patch. That solves 1. and 2. To
>> still do 3., add a signal handler for SIGINT in pg_ctl, which forwards
>> the SIGINT to the postmaster process. Thoughts on that?
>
> That seems like a nice idea.

Here's a patch to implement that. Seems to work. There is a small window
between launching postmaster and installing the signal handler, though,
where CTRL-C on pg_ctl will not abort the server launch. I think that's
acceptable.

Looking at the existing docs in the "Starting the Database Server"
section, and the pg_ctl reference page, I don't think we need to change
anything. This is the same user-visible behavior as before, except for
the case with a script like in Paul's original post. And that is almost
a bug fix: the manual says that pg_ctl "will start the server in the
background", and I think the new behavior matches that description
better than the old one. Perhaps we should mention something about how
CTRL-C will interrupt the server launch in "pg_ctl -w" mode, but that
isn't new, either.

I don't think we should backpatch this. We haven't heard any complaints
about this until now, and it seems plausible, although unlikely, that
someone might be relying on the current behavior.

- Heikki

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2018-12-30 20:18:53 Re: PostgreSQL vs SQL/XML Standards
Previous Message Thomas Munro 2018-12-30 19:49:40 Re: Shared Memory: How to use SYSV rather than MMAP ?