Return-Path: Delivered-To: apmail-httpd-dev-archive@www.apache.org Received: (qmail 81575 invoked from network); 15 Jan 2009 00:20:40 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 15 Jan 2009 00:20:40 -0000 Received: (qmail 11398 invoked by uid 500); 15 Jan 2009 00:20:33 -0000 Delivered-To: apmail-httpd-dev-archive@httpd.apache.org Received: (qmail 11342 invoked by uid 500); 15 Jan 2009 00:20:33 -0000 Mailing-List: contact dev-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list dev@httpd.apache.org Received: (qmail 11333 invoked by uid 99); 15 Jan 2009 00:20:33 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 14 Jan 2009 16:20:33 -0800 X-ASF-Spam-Status: No, hits=0.4 required=10.0 tests=DATE_IN_PAST_03_06,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of apache-dev@m.gmane.org designates 80.91.229.2 as permitted sender) Received: from [80.91.229.2] (HELO ciao.gmane.org) (80.91.229.2) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Jan 2009 00:20:24 +0000 Received: from root by ciao.gmane.org with local (Exim 4.43) id 1LNFxr-000439-5P for dev@httpd.apache.org; Thu, 15 Jan 2009 00:20:03 +0000 Received: from pd9e67af3.dip.t-dialin.net ([217.230.122.243]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 15 Jan 2009 00:20:03 +0000 Received: from steinbach by pd9e67af3.dip.t-dialin.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 15 Jan 2009 00:20:03 +0000 X-Injected-Via-Gmane: http://gmane.org/ To: dev@httpd.apache.org From: "Thomas Steinbach" Subject: Apache Shutdown - Win32 Date: Wed, 14 Jan 2009 19:58:07 +0100 Lines: 51 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset="utf-8"; reply-type=original Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: pd9e67af3.dip.t-dialin.net X-Newsreader: Microsoft Windows Mail 6.0.6001.18000 Sender: news X-Virus-Checked: Checked by ClamAV on apache.org Hello, I have a small win32 program which starts and stops apache (win) as a program (not service) in a hidden console. ---snip--- /* global vars */ STARTUPINFO g_sia; PROCESS_INFORMATION g_pia; [...] void StartApache() { g_sia.dwFlags = STARTF_USESHOWWINDOW; g_sia.wShowWindow = SW_HIDE; CreateProcess(NULL, "apache.exe...", NULL, NULL, FALSE, CREATE_NEW_PROCESS_GROUP, NULL, NULL, &g_sia, &g_pia); } ---snap--- using "CREATE_NEW_PROCESS_GROUP" described at: http://msdn.microsoft.com/en-us/library/ms684863(VS.85).aspx At the end I would like to shutdown apache in an "usual" way and sending an CTRL+C to the console. Using GenerateConsoleCtrlEvent(). See: http://msdn.microsoft.com/en-us/library/ms683155(VS.85).aspx btw: actually I terminate apache, using CreateToolhelp32Snapshot() and iterate all child processes and using TerminateProcess(). but I would prefer to generate an CTRL+C Signal ---snip--- void StopApache() { GenerateConsoleCtrlEvent(CTRL_C_EVENT, g_pia.dwProcessId); } ---snap--- but got an Error #6 = "The handle is invalid" with GetLastError() and nothing happens and apache is still runing. Why? And how can I shutdown apache in this way using the signal Ctrl+C Signal in Windows? The pid is a global var and contains the pid of the parent process. Should be valid - shouldn't it? Thomas