You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Davi Arnaut <da...@haxent.com.br> on 2006/05/26 12:14:38 UTC

[PATCH] properly set the parent pid on shutdown

Hi,

On WIN9X machines, before signaling the parent process in
ap_signal_parent() we ought to set the proper parent pid
retrieved by GetWindowThreadProcessId(). Otherwise, the
event will be signaled without being properly opened because
the parent  pid will remain the same as the calling process pid.

With this patch it's possible to stop the httpd daemon with
the standart -k stop signal on WIN9X.

--
Davi Arnaut

Index: server/mpm/winnt/service.c
===================================================================
--- server/mpm/winnt/service.c	(revision 409410)
+++ server/mpm/winnt/service.c	(working copy)
@@ -35,6 +35,7 @@
 #undef _WINUSER_
 #include <winuser.h>
 
+extern DWORD parent_pid;
 static char *mpm_service_name = NULL;
 static char *mpm_display_name = NULL;
 
@@ -1289,8 +1290,10 @@
          * provided the class is ApacheWin95ServiceMonitor
          */
         hwnd = FindWindow("ApacheWin95ServiceMonitor", mpm_service_name);
-        if (hwnd && GetWindowThreadProcessId(hwnd, &service_pid))
+        if (hwnd && GetWindowThreadProcessId(hwnd, &service_pid)) {
+            parent_pid = service_pid;
             globdat.ssStatus.dwCurrentState = SERVICE_RUNNING;
+        }
         else
         {
             globdat.ssStatus.dwCurrentState = SERVICE_STOPPED;
Index: server/mpm/winnt/mpm_winnt.c
===================================================================
--- server/mpm/winnt/mpm_winnt.c	(revision 409410)
+++ server/mpm/winnt/mpm_winnt.c	(working copy)
@@ -57,7 +57,7 @@
 
 OSVERSIONINFO osver; /* VER_PLATFORM_WIN32_NT */
 
-static DWORD parent_pid;
+DWORD parent_pid;
 DWORD my_pid;
 
 int ap_threads_per_child = 0;


Re: [PATCH] properly set the parent pid on shutdown

Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
Davi Arnaut wrote:
> On Fri, 26 May 2006 13:48:05 -0500
> "William A. Rowe, Jr." <wr...@rowe-clan.net> wrote:
> 
>>+1 on visual review.  Anyone have a win9x install handy to verify
>>that this works?  Sorry, none of my multiboots still boot 9x.
> 
> I've personally tested it on WIN98 (virtual machine).

Just a heads up... during development I saw varying behavior on 95, 98,
98SE and ME.  <shrug/>  I would appreciate if more that one person could
test this before we commit to 2.0 or 2.2 branch.  Perhaps I should create
a binary from the patch + 2.0.58/2.2.2 and let folks download that to
verify based on a plea to users@?

Bill

Re: [PATCH] properly set the parent pid on shutdown

Posted by Davi Arnaut <da...@haxent.com.br>.
On Fri, 26 May 2006 13:48:05 -0500
"William A. Rowe, Jr." <wr...@rowe-clan.net> wrote:

> +1 on visual review.  Anyone have a win9x install handy to verify
> that this works?  Sorry, none of my multiboots still boot 9x.

I've personally tested it on WIN98 (virtual machine).
 
> Davi Arnaut wrote:
> > Hi,
> > 
> > On WIN9X machines, before signaling the parent process in
> > ap_signal_parent() we ought to set the proper parent pid
> > retrieved by GetWindowThreadProcessId(). Otherwise, the
> > event will be signaled without being properly opened because
> > the parent  pid will remain the same as the calling process pid.
> > 
> > With this patch it's possible to stop the httpd daemon with
> > the standart -k stop signal on WIN9X.

--
Davi Arnaut
 


Re: [PATCH] properly set the parent pid on shutdown

Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
+1 on visual review.  Anyone have a win9x install handy to verify
that this works?  Sorry, none of my multiboots still boot 9x.

Davi Arnaut wrote:
> Hi,
> 
> On WIN9X machines, before signaling the parent process in
> ap_signal_parent() we ought to set the proper parent pid
> retrieved by GetWindowThreadProcessId(). Otherwise, the
> event will be signaled without being properly opened because
> the parent  pid will remain the same as the calling process pid.
> 
> With this patch it's possible to stop the httpd daemon with
> the standart -k stop signal on WIN9X.
> 
> --
> Davi Arnaut
> 
> Index: server/mpm/winnt/service.c
> ===================================================================
> --- server/mpm/winnt/service.c	(revision 409410)
> +++ server/mpm/winnt/service.c	(working copy)
> @@ -35,6 +35,7 @@
>  #undef _WINUSER_
>  #include <winuser.h>
>  
> +extern DWORD parent_pid;
>  static char *mpm_service_name = NULL;
>  static char *mpm_display_name = NULL;
>  
> @@ -1289,8 +1290,10 @@
>           * provided the class is ApacheWin95ServiceMonitor
>           */
>          hwnd = FindWindow("ApacheWin95ServiceMonitor", mpm_service_name);
> -        if (hwnd && GetWindowThreadProcessId(hwnd, &service_pid))
> +        if (hwnd && GetWindowThreadProcessId(hwnd, &service_pid)) {
> +            parent_pid = service_pid;
>              globdat.ssStatus.dwCurrentState = SERVICE_RUNNING;
> +        }
>          else
>          {
>              globdat.ssStatus.dwCurrentState = SERVICE_STOPPED;
> Index: server/mpm/winnt/mpm_winnt.c
> ===================================================================
> --- server/mpm/winnt/mpm_winnt.c	(revision 409410)
> +++ server/mpm/winnt/mpm_winnt.c	(working copy)
> @@ -57,7 +57,7 @@
>  
>  OSVERSIONINFO osver; /* VER_PLATFORM_WIN32_NT */
>  
> -static DWORD parent_pid;
> +DWORD parent_pid;
>  DWORD my_pid;
>  
>  int ap_threads_per_child = 0;
> 
> 
>