logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: want to write a C code in Windows to kill the appache.
Author
ashwani_ap



Joined: 29 Aug 2007
Posts: 47
Location: Bangalore

PostPosted: Wed 29 Aug '07 11:00    Post subject: want to write a C code in Windows to kill the appache. Reply with quote

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: 7298
Location: Germany, Next to Hamburg

PostPosted: Wed 29 Aug '07 11:51    Post subject: Reply with quote

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
Wink

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

PostPosted: Wed 29 Aug '07 12:25    Post subject: My Problem statement goes like this Reply with quote

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: 7298
Location: Germany, Next to Hamburg

PostPosted: Wed 29 Aug '07 13:53    Post subject: Reply with quote

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

PostPosted: Wed 29 Aug '07 14:06    Post subject: Answer for Why do you need to kill apache Reply with quote

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

PostPosted: Wed 29 Aug '07 14:51    Post subject: Reply with quote

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

PostPosted: Wed 29 Aug '07 15:36    Post subject: I tried but that code is not working. Reply with quote

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

PostPosted: Fri 31 Aug '07 17:07    Post subject: Code in C Windows to kill all child process httpd.exe. Reply with quote

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


Reply to topic   Topic: want to write a C code in Windows to kill the appache. View previous topic :: View next topic
Post new topic   Forum Index -> Apache