Re: [HACKERS] postmaster disappears - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [HACKERS] postmaster disappears
Date
Msg-id 21449.937922399@sss.pgh.pa.us
Whole thread Raw
In response to postmaster disappears  (Tatsuo Ishii <t-ishii@sra.co.jp>)
Responses Re: [HACKERS] postmaster disappears  (Tatsuo Ishii <t-ishii@sra.co.jp>)
List pgsql-hackers
Tatsuo Ishii <t-ishii@sra.co.jp> writes:
> In this case errno=ECHILD has been returned that makes postmaster
> exiting. This could happen if SIGCHLD raised between select() call and
> the next if (errno=...) statement. One of the solution would be
> ignoring ECHILD as well as EINTR. Included are patches for this.

Hmm.  What you are saying, I guess, is that SIGCHLD is raised,
reaper() executes, and then when control continues in the main loop
the errno left over from reaper()'s last kernel call is what's seen,
instead of the one returned by signal().

Seems to me that the correct fix is to have reaper() save and restore
the outer value of errno, not to hack the main line to ignore the
most probable state left over from reaper().  Otherwise you still choke
if some other value gets returned from whatever call reaper() does last.
Moreover, you're not actually checking what the select() did unless
you do it that way.

Curious that this sort of problem is not seen more often --- I wonder
if most Unixes arrange to save/restore errno around a signal handler
for you?
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [HACKERS] create table and default 'now' problem ?
Next
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] Re: HISTORY for 6.5.2