Re: Sharing database handles across forked child processes - Mailing list pgsql-general

From Tom Lane
Subject Re: Sharing database handles across forked child processes
Date
Msg-id 18873.1194974812@sss.pgh.pa.us
Whole thread Raw
In response to Re: Sharing database handles across forked child processes  (Martijn van Oosterhout <kleptog@svana.org>)
Responses Re: Sharing database handles across forked child processes  (dan@sidhe.org)
List pgsql-general
Martijn van Oosterhout <kleptog@svana.org> writes:
> On Tue, Nov 13, 2007 at 12:02:31PM -0500, dan@sidhe.org wrote:
>> How does Postgres handle sharing database handles across child processes?
>> That is, if I have a process that opens a connection to the database and
>> then forks a few child processes, what happens?
>>
>> Can the child processes safely use the handle?

> No.

For some time now, libpq has set FD_CLOEXEC on the socket connection to
the backend, which ensures that child processes won't be able to mess up
the parent's database connection.  However it sounded like Dan might be
doing fork without exec, in which case he's definitely at risk ...

            regards, tom lane

pgsql-general by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: Sharing database handles across forked child processes
Next
From: Reg Me Please
Date:
Subject: Re: Postgres table size