Sucess!I ended up not going down the GenerateConsoleEvent but your suggestion inspired me to do some digging. I read on the win32 api help a while that GenerateConsoleEvent will basically just call the registered the even handler, so I searched through the source code to see if I could find it, and yup found it. Then followed a bit of code and realised something, apache creates events to signal different things.
Here is a little helper function I wrote so other people can benefit from what I have found (signal is "shutdown" or "restart")
bool SendApacheSignal(DWORD pid, char *signal) { char buff[128]; HANDLE event = NULL; if (sprintf(buff, "ap%d_%s", pid, signal)) { event = ::OpenEvent(EVENT_MODIFY_STATE, false, buff); } return event && ::SetEvent(event); } This is basically what httpd -k stop does on Win 9x but not XP Hope some of you find that useful and thanks for the inspiration Eric, Matt Matthew Gregory wrote:
Thanks for this, I had tried the GenerateConsoleEvent api before without success, although reading that page the author is creating a remote thread to call the api from within the Apache process rather than externally so I'll play around with that.Thanks, Matt Eric Covener wrote:On Thu, May 28, 2009 at 7:19 AM, Matthew Gregory <matthew+apache@xxxxxxxxxxx> wrote:My question is this: how can I gracefully close apache? The docs say to use "httpd -k stop" but on our target platforms this always tries to stop the service but we are actually running as a console. There is mention of usingkill on unix but I cannot find a suitable windows equivilant.I've used e a little windows utility, SendSignal.exe, to send cntrl-break to a similar a program in some automation. http://www.latenighthacking.com/projects/2003/sendSignal/ Unfortunately it didn't look like any of the sysinsternals tools would do it, but I may have just missed it.--------------------------------------------------------------------- The official User-To-User support forum of the Apache HTTP Server Project. See <URL:http://httpd.apache.org/userslist.html> for more info. To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx " from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx
--------------------------------------------------------------------- The official User-To-User support forum of the Apache HTTP Server Project. See <URL:http://httpd.apache.org/userslist.html> for more info. To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx " from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx