BUG #4602: child processes inherit database socket - Mailing list pgsql-bugs

From Jasen Betts
Subject BUG #4602: child processes inherit database socket
Date
Msg-id 200901060956.n069uYVX036518@wwwmaster.postgresql.org
Whole thread Raw
Responses Re: BUG #4602: child processes inherit database socket
List pgsql-bugs
The following bug has been logged online:

Bug reference:      4602
Logged by:          Jasen Betts
Email address:      jasen@treshna.com
PostgreSQL version: 8.3
Operating system:   linux
Description:        child processes inherit database socket
Details:

libpq creates sockets to the server without CLOEXEC.

as a result child processes inherit instances of the database socket

this wastes resources, and in some cases seems to keep the backend around
after the client has expired.

unless there's a reaon why duplicating the sockets is useful it can be
stopped like this:

  {
  int dflags =  fcntl( socket_fd, F_GETFD );
  fcntl( socket_fd, F_SETFD , dflags | CLOEXEC );
  }

pgsql-bugs by date:

Previous
From: "V KUMAR"
Date:
Subject: BUG #4601: Data saving and opening problem
Next
From: Tom Lane
Date:
Subject: Re: BUG #4602: child processes inherit database socket