[pgpool-committers: 3335] pgpool: Fix usage of wait(2) in pgpool main process

Tatsuo Ishii ishii at postgresql.org
Thu Jul 7 15:55:48 JST 2016


Fix usage of wait(2) in pgpool main process

Per [pgpool-hackers: 1444]. Here is the copy of the message:

Hi Usama,

I have noticed that the usage of wait(2) in pgpool main could cause
infinite wait in the system call.

    /* wait for all children to exit */
    do
    {
        wpid = wait(NULL);
    }while (wpid > 0 || (wpid == -1 && errno == EINTR));

When child process dies, SIGCHLD signal is raised and wait(2) knows
the event. However, multiple child death does not necessarily creates
exact same number of SIGCHLD signal as the number of dead children and
wait(2) could wait for an event which never happens in this case. I
actually encountered this situation while testing pgpool-II. Solution
is, to use waitpid(2) instead of wait(2).

Branch
------
V3_4_STABLE

Details
-------
http://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=514dc0b78809dbc6e107288c04b5b6c8fa492eab

Modified Files
--------------
src/main/pgpool_main.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)



More information about the pgpool-committers mailing list