Re: Possible substitute for PostmasterIsAlive polling loops

From: Florian Pflug <fgp(at)phlo(dot)org>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Possible substitute for PostmasterIsAlive polling loops
Date: 2011-02-24 16:36:39
Message-ID: 06DE5845-AF8A-465F-A903-6DEBD986F249@phlo.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Feb24, 2011, at 04:14 , Robert Haas wrote:
> On Wed, Feb 23, 2011 at 4:54 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> IOW, at least on Linux, you *can* arrange to get a signal when your
>> parent process dies.
>
> That's pretty cool.
>
>> Not sure how ugly it'd be to use this call when available and a time
>> delay when not, but it's something to think about.
>
> Yeah. It may be worth thinking about whether we want to use the
> postmaster-pipe trick someone was proposing. That might be more
> portable.

FWIW, I did some experiments which this when it was discussion a while ago.

To actually get a signal when the parent dies, I set the FASYNC flag
on the pipe's receiving end's fd. To be able to signal multiple children
using only one pipe, I set the fd's owner to -getgrp() using
fcntl(F_SETOWN). On both linux and OSX 10.6 this caused SIGIO to be sent
to all processes in the process group once sending end of the pipe was
closed.

I don't have access to any other Unixes to test this on, but I since it
works on OSX chances are high that it'll work on FreeBSD also.

best regards,
Florian Pflug

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2011-02-24 16:37:38 Re: wCTE: about the name of the feature
Previous Message Marko Tiikkaja 2011-02-24 16:33:08 Re: wCTE: about the name of the feature