btherl Posted March 21, 2006 Share Posted March 21, 2006 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? Quote Link to comment https://forums.phpfreaks.com/topic/5391-children-close-parents-pg-connection/ Share on other sites More sharing options...
Jenk Posted September 15, 2006 Share Posted September 15, 2006 Use a persistant connection:http://www.php.net/manual/en/function.pg-pconnect.phpBut remember to use pg_close($linkid); else the connection will remain open until PG's own timeout clause is met. Quote Link to comment https://forums.phpfreaks.com/topic/5391-children-close-parents-pg-connection/#findComment-92526 Share on other sites More sharing options...
btherl Posted September 18, 2006 Author Share Posted September 18, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/5391-children-close-parents-pg-connection/#findComment-93844 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.