Re: SIGCHLD handler in Postgres C function.

Поиск
Список
Период
Сортировка
От Tatsuo Ishii
Тема Re: SIGCHLD handler in Postgres C function.
Дата
Msg-id 20010722092803N.t-ishii@sra.co.jp
обсуждение исходный текст
Ответ на Re: SIGCHLD handler in Postgres C function.  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: SIGCHLD handler in Postgres C function.  (Bill Studenmund <wrstuden@zembu.com>)
Список pgsql-hackers
> 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.
> 
> Hmm.  A possibly related bit of ugliness can be found in
> src/backend/commands/dbcommands.c, where we ignore ECHILD after
> a system() call:
> 
>     ret = system(buf);
>     /* Some versions of SunOS seem to return ECHILD after a system() call */
>     if (ret != 0 && errno != ECHILD)
>     {
> 
> Interesting, no?  I wonder whether we could get rid of that kluge
> if the signal handler was SIG_DFL rather than SIG_IGN.  Can anyone
> try this on one of the affected versions of SunOS?  (Tatsuo, you
> seem to have added the ECHILD exception on May 25 2000; the commit
> message mentions Solaris but not which version.  Could you try it?)

It was Solaris 2.6.

>Subject: [HACKERS] Solaris 2.6 problems
>From: Tatsuo Ishii <t-ishii@sra.co.jp>
>To: pgsql-hackers@postgresql.org
>Cc: t-ishii@sra.co.jp
>Date: Wed, 24 May 2000 18:28:25 +0900
>X-Mailer: Mew version 1.93 on Emacs 19.34 / Mule 2.3 (SUETSUMUHANA)
>
>Hi, I have encountered a really strange problem with PostgreSQL 7.0 on
>Solaris 2.6/Sparc. The problem is that createdb command or create
>database SQL always fails. Inspecting the output of truss shows that
>system() call in createdb() (commands/dbcomand.c) fails because
>waitid() system call in system() returns error no. 10 (ECHILD).
>
>This problem was not in 6.5.3, so I checked the source of it. The
>reason why 6.5.3's createdb worked was that it just ignored the return
>code of system()!
>
>It seems that we need to ignore an error from system() if the error is
>ECHILD on Solaris.
>
>Any idea?
>
>BTW, I have compiled PostgreSQL with egcs 2.95 with/without
>optimization.
>--
>Tatsuo Ishii
>


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

Предыдущее
От: Philip Warner
Дата:
Сообщение: Re: Incomplete idea about views and INSERT...RETURNING
Следующее
От: Tatsuo Ishii
Дата:
Сообщение: Re: Pgbench Performance on PGSQL