Stopping httpd causes a process started from perl CGI script to receive SIGTERM

Posted by Pranav Pal on Stack Overflow See other posts from Stack Overflow or by Pranav Pal
Published on 2013-07-01T07:37:41Z Indexed on 2013/07/01 17:08 UTC
Read the original article Hit count: 272

Filed under:
|
|
|
|

I am running a shell script from a perl CGI script:

#!/usr/bin/perl
my $command = "./script.sh &";
my $pid = fork();
if (defined($pid) && $pid==0) {
        # background process
        system( $command );
}

The shell script looks like this:

#!/bin/sh
trap 'echo trapped' 15
tail -f test.log

When I run the CGI script from browser, and then stop httpd using /etc/init.d/httpd stop, the script receives a SIGTERM signal.

I was expecting the script to run as a separate process and not be tied in anyway to httpd. Though I can trap the SIGTERM, I would like to understand why the script is receiving SIGTERM at all.

What wrong am I doing here? I am running RHEL 5.8 and Apache HTTP server 2.4.

Thanks, Pranav

© Stack Overflow or respective owner

Related posts about perl

Related posts about apache