Re: A bit of PG archeology uncovers an interesting Linux/Unix factoid

Поиск
Список
Период
Сортировка
От Chapman Flack
Тема Re: A bit of PG archeology uncovers an interesting Linux/Unix factoid
Дата
Msg-id 56C27277.6080108@anastigmatix.net
обсуждение исходный текст
Ответ на A bit of PG archeology uncovers an interesting Linux/Unix factoid  (Greg Stark <stark@mit.edu>)
Ответы Re: A bit of PG archeology uncovers an interesting Linux/Unix factoid  (Greg Stark <stark@mit.edu>)
Список pgsql-hackers
On 02/15/16 13:42, Greg Stark wrote:

>     (it returns error with errno ECHILD upon successful completion of commands).
>     This fix ignores an error from system() if errno == ECHILD.
> 
> It looks like Linux now behaves similarly,

It seems to be official, in the Single Unix Specification:
http://pubs.opengroup.org/onlinepubs/7908799/xsh/sigaction.html

SA_NOCLDWAIT   If set, and sig equals SIGCHLD, child processes of the calling   processes will not be transformed into
zombieprocesses when they   terminate. If the calling process subsequently waits for its   children, and the process
hasno unwaited for children that were   transformed into zombie processes, it will block until all of its   children
terminate,and wait(), wait3(), waitid() and waitpid() will   fail and set errno to [ECHILD]. Otherwise, terminating
child  processes will be transformed into zombie processes, unless SIGCHLD   is set to SIG_IGN.
 

> So just in case anyone else wants to use system() in Postgres or
> indeed any other Unix application that twiddles with the SIGCHILD
> handler this is something to beware of. It's not entirely clear to me
> that the mention of SA_NOCLDWAIT is the only way to get this
> behaviour, at least one stackoverflow answer implied just setting
> SIG_IGN was enough.

Yup:

• If a process sets the action for the SIGCHLD signal to SIG_IGN, the   behaviour is unspecified, except as specified
below.If the action   for the SIGCHLD signal is set to SIG_IGN, child processes of the   calling processes will not be
transformedinto zombie processes when   they terminate. If the calling process subsequently waits for its   children,
andthe process has no unwaited for children that were   transformed into zombie processes, it will block until all of
its  children terminate, and wait(), wait3(), waitid() and waitpid() will   fail and set errno to [ECHILD].
 

-Chap



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

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: Re: [COMMITTERS] pgsql: Introduce group locking to prevent parallel processes from deadl
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Re: [COMMITTERS] pgsql: Introduce group locking to prevent parallel processes from deadl