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 zombie processes when they terminate. If the calling process subsequently waits for its children, and the 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]. 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 transformed into zombie processes when they terminate. If the calling process subsequently waits for its children, and the 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 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers