Jump to content

Archived

This topic is now archived and is closed to further replies.

btherl

Children close parent's PG connection!

Recommended Posts

I have a script which opens a connection with pg_connect(), and then forks off several children. When the children are finished, they exit.

Unfortunately, these children inherit the parent's postgres connection, and they close this connection when they exit.

Is there any way to stop the children from closing the connection?

Share this post


Link to post
Share on other sites
Use a persistant connection:

http://www.php.net/manual/en/function.pg-pconnect.php

But remember to use pg_close($linkid); else the connection will remain open until PG's own timeout clause is met.

Share this post


Link to post
Share on other sites
Thanks for the suggestion!  I solved this by using pcntl_exec(), thus avoiding php's shutdown code.

pg_pconnect() doesn't work unfortunately, as the children believe they are the only running php process.  So they shut down all persistent connections on exit.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.