# Postgres (or pg) closes backend on exit

**URL:** <https://www.ruby-forum.com/t/postgres-or-pg-closes-backend-on-exit/148110>\
**Category:** Ruby\
**Created:** [September 9, 2008, 1:00pm UTC](https://www.ruby-forum.com/t/postgres-or-pg-closes-backend-on-exit/148110 "2008-09-09T13:00:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hanholl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/a87d85/32.png) [@hanholl](https://www.ruby-forum.com/u/hanholl)\
**Post date:** [September 9, 2008, 1:00pm UTC](https://www.ruby-forum.com/t/postgres-or-pg-closes-backend-on-exit/148110/1 "2008-09-09T13:00:58Z")

</div>

(This is ruby-1.8.[46] on Linux).

When I strace the following script:  
#!usr/bin/ruby -w  
require ‘postgres’  
connection = PGconn.connect(nil,nil,nil,nil,‘palga’, ‘palga’,  
‘Patologi’)

# end-of-script

I see that it ends with:

send(3, “X\0\0\0\4”, 5, 0) = 5  
close(3) = 0

In other words, the script somehow shuts down the backend server on  
exit.  
Normally this is fine, but if it’s a fork of a process that is supposed  
to  
continue with the same  
backend it’s a problem.  
Does anyone know _how_ this is achieved, and therefore how I can disable  
it,  
I tried GC.disable (doesn’t work) and exit! (does work, but is a bit  
heavy  
handed).

Thanks in advance for any help,

Han H.
