Bug 88611 - Processes started via CGI die when httpd dies
Summary: Processes started via CGI die when httpd dies
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: postgresql
Version: 9
Hardware: All
OS: Linux
Target Milestone: ---
Assignee: Tom Lane
QA Contact: David Lawrence
Depends On:
TreeView+ depends on / blocked
Reported: 2003-04-11 13:17 UTC by Sepp Rudel
Modified: 2013-07-03 02:59 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2006-10-18 18:08:17 UTC

Attachments (Terms of Use)

Description Sepp Rudel 2003-04-11 13:17:43 UTC
Description of problem:

Using a simple perl script:

if ($< ne 0)
         exec ("sudo /var/www/cgi-bin/test.cgi");
print "Content-Type: text/html\n\n";
system("/etc/init.d/postgresql stop");
sleep 5;
system("/etc/init.d/postgresql start");
sleep 10;
system("/etc/init.d/httpd restart");
exit 0;

works perfecty when executed from command line (as root or via sudo). But when
executing via apache/cgi/sudo, postgres/postmaster processes die instantly when
httpd is stopped.

Version-Release number of selected component (if applicable):

Version from RHL7.3+errata.

How reproducible:


Steps to Reproduce:
1. Create the script above
2. Tweak sudo
3. Run it via apache/cgi

Actual results:

PostgreSQL dies when httpd is stopped.

Expected results:

PostgreSQL continues running when httpd is stopped.

Additional info:

This problem is seems to exists with ucd-snmp as well - it seems that this is
somehow related to the fact the PostgreSQL and ucd-snmp both use su in their
init scripts. Any patches/workarounds/comments would be highly appreciated.

Comment 1 Sepp Rudel 2003-05-06 06:41:37 UTC
The problem exists with RHL9, too. The difference between RHL7.3 and RHL9 is
that with RHL7.3 httpd restart is completed, with RHL9 not (i.e., httpd is only
stopped). But the main point is that why PostgreSQL dies?

Comment 2 Sepp Rudel 2003-06-02 07:15:19 UTC
So, any news on this one? Or is this the right component?

Comment 3 Sepp Rudel 2003-07-03 13:57:07 UTC
Trying my luck with another component.

Comment 4 Sepp Rudel 2003-08-18 11:36:01 UTC
Any news from this? A sole "RTFM" comment would be warmly welcomed, if that's
all what's needed!

Comment 5 Joe Orton 2003-12-01 14:29:41 UTC
What user is the CGI script running as?  Unless it's root (which you
shouldn't run CGI scripts as) this is probably never going to work

Comment 6 Tom Lane 2004-04-05 20:24:47 UTC
I would guess that this is somehow making the postmaster part of the
process group for httpd, and that the shutdown method used for httpd
sends SIGTERM to the whole process group.  (Seems a bit odd though
since I'd have thought spawning via "su -c" would put the child
process into its own group.)

If this theory is correct then adding -S to the postmaster switches in
the PG start script (put it in the -o stuff in the pg_ctl start call)
might make the difficulty go away.  I'm not familiar enough with httpd
to ensure I'm reproducing your test case --- could you try this and

Note that I'd not want to make this change to the official script, as
it would interfere with plans to support logging to stderr better. 
However it might do as a workaround, and anyway we need to be sure we
understand the cause of the problem before thinking about "real"

Comment 7 Bill Nottingham 2006-10-18 18:08:17 UTC
Red Hat Linux is no longer supported by Red Hat, Inc. If you are still
running Red Hat Linux, you are strongly advised to upgrade to a
current Fedora Core release or Red Hat Enterprise Linux or comparable.
Some information on which option may be right for you is available at

Red Hat apologizes that these issues have not been resolved yet. We do
want to make sure that no important bugs slip through the cracks.
If this issue is still present in a current Fedora Core release, please
open a new bug with the relevant information.

Closing as CANTFIX.

Note You need to log in before you can comment on or make changes to this bug.