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

From: Greg Stark <stark(at)mit(dot)edu>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: A bit of PG archeology uncovers an interesting Linux/Unix factoid
Date: 2016-02-15 18:42:49
Message-ID: CAM-w4HMLmCwxCyVfxbbrA=jOr=2VL=mrm8VsJHUv7LWYX7H6Fw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

For reasons, I was trying to compile older versions of Postgres and
ran into a strange behaviour where system() worked normally but then
returned -1 with errno set to ECHILD. And surprisingly it looks like
we've seen this behaviour in the past but on a Solaris:

commit 07d4d36aae79cf2ac365e381ed3e7ce62dcfa783
Author: Tatsuo Ishii <ishii(at)postgresql(dot)org>
Date: Thu May 25 06:53:43 2000 +0000

On solaris, createdb/dropdb fails because of strange behavior of system().
(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, in fact there's a Redhat
notice about this causing similar headaches in Oracle:
https://access.redhat.com/solutions/37218

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.

--
greg

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2016-02-15 19:02:41 Re: xlc atomics
Previous Message Peter Geoghegan 2016-02-15 18:15:55 Re: Re: Reusing abbreviated keys during second pass of ordered [set] aggregates