Re: SIGCHLD handler in Postgres C function.

Поиск
Список
Период
Сортировка
От Bill Studenmund
Тема Re: SIGCHLD handler in Postgres C function.
Дата
Msg-id Pine.NEB.4.33.0107271723400.306-100000@candlekeep.home-net.internetconnect.net
обсуждение исходный текст
Ответ на Re: SIGCHLD handler in Postgres C function.  (Tatsuo Ishii <t-ishii@sra.co.jp>)
Ответы Re: SIGCHLD handler in Postgres C function.  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On Sun, 22 Jul 2001, Tatsuo Ishii wrote:

> > spshealy@yahoo.com writes:
> > > I have written a postgres C function that
> > > uses a popen linux system call. Orginally when I first tried it I kept
> > > getting an ECHILD.  I read a little bit more on the pclose function
> > > and the wait system calls and discoverd that on LINUX if the signal
> > > handler for  SIGCHLD is set to SIG_IGN you will get the ECHILD error
> > > on pclose(or wait4 for that matter).  So I did some snooping around in
> > > the postgres backend code and found that in the traffic cop that the
> > > SIGCHLD signal handler is set to SIG_IGN.  So in my C function right
> > > before the popen call I set the signal handler for SIGCHLD to SIG_DFL
> > > and right after the pclose I set it back to SIG_IGN.  I tested this
> > > and it seems to solve my problem.

Just ignore ECHILD. It's not messy at all. :-) It sounds like your kernel
is using SIG_IGN to do the same thing as the SA_NOCLDWAIT flag in *BSD
(well NetBSD at least). When a child dies, it gets re-parrented to init
(which is wait()ing). init does the child-died cleanup, rather than the
parent needing to. That way when the parent runs wait(), there is no
child, so you get an ECHILD.

All ECHILD is doing is saying there was no child. Since we aren't really
waiting for the child, I don't see how that's a problem.

Take care,

Bill



В списке pgsql-hackers по дате отправления:

Предыдущее
От: "Mikheev, Vadim"
Дата:
Сообщение: RE: Performance TODO items
Следующее
От: "Mikheev, Vadim"
Дата:
Сообщение: RE: Performance TODO items