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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
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 20:56:45
Message-ID: 13252.1546203405@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Heikki Linnakangas <hlinnaka(at)iki(dot)fi> writes:
> 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.

Hm ... you could partially forestall that by installing the signal handler
first. But then you have to assume that storing a pid_t variable is
atomic, which perhaps is bad? Though it's hard to credit that any
platform would need multiple instructions to do that. Also, I suppose
there's still a window, since the fork will necessarily occur some time
before you're able to store the child PID into the variable.

Another possible idea is to block SIGINT from before the fork till after
you've set the variable. But that seems overly complicated, and perhaps
not without problems of its own. So on the whole I concur with your
approach.

> Forgot attachment, here it is.

This comment needs copy-editing:

+ * If the user hits interrupts the startup (e.g. with CTRL-C), we'd

Looks good otherwise.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Petr Jelinek 2018-12-30 21:23:08 Synchronizing slots from primary to standby
Previous Message Heikki Linnakangas 2018-12-30 20:41:07 Re: [Patch] Create a new session in postmaster by calling setsid()