Re: [Patch] Create a new session in postmaster by calling setsid() - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [Patch] Create a new session in postmaster by calling setsid()
Date
Msg-id 13252.1546203405@sss.pgh.pa.us
Whole thread Raw
In response to Re: [Patch] Create a new session in postmaster by calling setsid()  (Heikki Linnakangas <hlinnaka@iki.fi>)
Responses Re: [Patch] Create a new session in postmaster by calling setsid()
List pgsql-hackers
Heikki Linnakangas <hlinnaka@iki.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


pgsql-hackers by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: [Patch] Create a new session in postmaster by calling setsid()
Next
From: Petr Jelinek
Date:
Subject: Synchronizing slots from primary to standby