Author |
|
ashwani_ap
Joined: 29 Aug 2007 Posts: 47 Location: Bangalore
|
Posted: Wed 29 Aug '07 11:00 Post subject: want to write a C code in Windows to kill the appache. |
|
|
Hi,
I want to write a C Code for both Windows and Linux to start and terminate the httpd.exe shown in the task manager. I am using Apache2.2.4. It reports two httpd.exe in the task manager with diff PID.
My httpd.exe location is "C:\\Apache2\\bin\\httpd.exe"
Please guide me urgently. |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
Posted: Wed 29 Aug '07 11:51 Post subject: |
|
|
There is no fault! httpd.exe always start two instances. One Parent and one child process. So you don't have to kill the second process.
Under Linux in prefork there can be more than 8 processes
But if you realy want to kill it (you shouldn't) you don't have to write a programm. There ist under XP and 2003 TASKKILL
taskkill /f /IM httpd.exe
it is not recommend to kill one of these processes! |
|
Back to top |
|
ashwani_ap
Joined: 29 Aug 2007 Posts: 47 Location: Bangalore
|
Posted: Wed 29 Aug '07 12:25 Post subject: My Problem statement goes like this |
|
|
Actually, I have one daemon which when executed in turn call a function which will invoke the Apache httpd.exe.
And when this running daemon comes down it will call another module which should bring the running apache web server cleanly.
How should I write the code in Windows. I should kill the Apache through the PID of the parent PID by using some flags, etc. I am not clear on this. |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
Posted: Wed 29 Aug '07 13:53 Post subject: |
|
|
kill the parent!
Apache creates while running a pid file where you can read out the pid from the parent process. Where it is located, is defined in the httpd.conf
e.g.
Code: |
PidFile C:/Apache2/logs/httpd.pid
|
The main question is: Why do you need to kill apache? Is it a problem to run it all the time? |
|
Back to top |
|
ashwani_ap
Joined: 29 Aug 2007 Posts: 47 Location: Bangalore
|
Posted: Wed 29 Aug '07 14:06 Post subject: Answer for Why do you need to kill apache |
|
|
Actually,
The role of the Apache web server in my application is to just launch the GUI of my application to the clients browser once he send the request throught he "hostname:portno" that's it. After this there is no role of the server between client and server. The communication between the client and server will be through RPC, etc.
The main application daemon should control the life of the web server. If the main daemon dies it should kill the web server also.
I want write a function that will be called by the main daemon when it dies so that it will also bring the web server down. |
|
Back to top |
|
tdonovan Moderator
Joined: 17 Dec 2005 Posts: 611 Location: Milford, MA, USA
|
Posted: Wed 29 Aug '07 14:51 Post subject: |
|
|
Starting and stopping Apache from another program was discussed in this post back in March.
-tom- |
|
Back to top |
|
ashwani_ap
Joined: 29 Aug 2007 Posts: 47 Location: Bangalore
|
Posted: Wed 29 Aug '07 15:36 Post subject: I tried but that code is not working. |
|
|
HI,
I tried with that code. I am able to compile successfully, but that code is not starting the httpd.exe when executed. |
|
Back to top |
|
ashwani_ap
Joined: 29 Aug 2007 Posts: 47 Location: Bangalore
|
Posted: Fri 31 Aug '07 17:07 Post subject: Code in C Windows to kill all child process httpd.exe. |
|
|
I want some Code in C for Windows platform to kill all child process ( here httpd.exe) through the parent process PID. we don't know the child process PID. |
|
Back to top |
|