httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ashwani Kumar Sharma" <>
Subject RE: Want to kill Apache process when its parent process gets killed.
Date Tue, 11 Sep 2007 11:10:41 GMT
Hi Jeff,

Thanks for your reply. 

The httpd.exe of Apache web server has two processes running in windows.
When we kill the parent httpd.exe the child httpd.exe is still running and
listening to the web request. I don't want this.

I want to modify this in such a way that if I kill the parent httpd.exe
through following code, the child process should also get killed. How is it
possible? Please guide me. It's very urgent.

		hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, pid);
		if (hProcess == NULL) return FALSE;
		dwError = ERROR_SUCCESS;
		if (!TerminateProcess(hProcess, (DWORD)-1))
			dwError = GetLastError();

where pid is the parent process id.

Thanks and Regards,
Ashwani Sharma
Mob: 09916454843
Off: +91-80-26265053

-----Original Message-----
From: Jeff Trawick [] 
Sent: Tuesday, September 11, 2007 4:15 PM
Subject: Re: Want to kill Apache process when its parent process gets killed.

On 9/10/07, Ashwani Kumar Sharma <> wrote:

> In my application I am spawning httpd.exe from the parent process.
> My requirement is that:
> In the Abnormal termination of the parent process. The Apache should keep
> looking for its parent process. If the parent process is not present
>        then the Apache web server should also kill itself.
> How can I implement the 2nd point?

not even a half-baked idea:

Somebody gets the monitor hook called from the Windows MPM (i.e.,
fixes Apache on Windows to call a hook that is provided on

   General idea (mpm_winnt.c)

    /* Wait for shutdown or restart events or for child death */
    winnt_mpm_state = AP_MPMQ_RUNNING;
    do {
        rv = WaitForMultipleObjects(NUM_WAIT_HANDLES, (HANDLE *)
event_handles, FALSE, something-that-means-one-second);
       if (rv == WAIT_TIMEOUT) {
    } while (rv == WAIT_TIMEOUT);

(remove existing check for WAIT_TIMEOUT that considers it a fatal error)

Your application starts httpd.exe with a define like


and a config that loads a custom plug-in module provided by you which
implements the monitor hook that checks for when that pid goes away.

???How to make the monitor hook take down httpd?  apache -k stop???

This message (including attachment if any) is confidential and may be privileged. If you have
received this message by mistake please notify the sender by return e-mail and delete this
message from your system. Any unauthorized use or dissemination of this message in whole or
in part is strictly prohibited.
E-mail may contain viruses. Before opening attachments please check them for viruses and defects.
While MindTree Consulting Limited (MindTree) has put in place checks to minimize the risks,
MindTree will not be responsible for any viruses or defects or any forwarded attachments emanating
either from within MindTree or outside.
Please note that e-mails are susceptible to change and MindTree shall not be liable for any
improper, untimely or incomplete transmission.
MindTree reserves the right to monitor and review the content of all messages sent to or from
MindTree e-mail address. Messages sent to or from this e-mail address may be stored on the
MindTree e-mail system or else where.

View raw message