cvs server: Diffing .
Index: signals.c
===================================================================
RCS file: /home/cvspublic/apr/threadproc/win32/signals.c,v
retrieving revision 1.18
diff -u -r1.18 signals.c
--- signals.c   12 Feb 2002 21:59:01 -0000  1.18
+++ signals.c   15 Feb 2002 21:16:37 -0000
@@ -65,10 +65,61 @@
 #include <sys/wait.h>
 #endif
 
-/* Windows only really support killing process, but that will do for now. */
+#ifndef _WIN32_WCE
+typedef HANDLE (__stdcall * PFNCREATERTHRD)(HANDLE, LPSECURITY_ATTRIBUTES, DWORD,
+                                            LPTHREAD_START_ROUTINE, LPVOID, DWORD,
+                                            LPDWORD);
+#endif
+/* If we are running NT try to create the remote thread
+ * that runs in the virtual address space of child process.
+ * If that fails kill it with the plain old TerminateProcess.
+ */
 APR_DECLARE(apr_status_t) apr_proc_kill(apr_proc_t *proc, int signal)
 {
     if (proc->hproc != NULL) {
+#ifndef _WIN32_WCE
+        if (apr_os_level >= APR_WIN_NT ) {
+            PFNCREATERTHRD pfn_remotethread;            
+            apr_uint32_t exit_code = -1; /* Could be something that we could test */ 
+            apr_uint32_t rtid, stat;
+            HANDLE rt = NULL, dup = NULL;
+            BOOL isok;
+
+            pfn_remotethread = (PFNCREATERTHRD)GetProcAddress(
+                                               GetModuleHandleA("KERNEL32.DLL"),
+                                               "CreateRemoteThread");
+            isok = DuplicateHandle(GetCurrentProcess(), 
+                                   proc->hproc, 
+                                   GetCurrentProcess(), 
+                                   &dup, 
+                                   PROCESS_ALL_ACCESS, 
+                                   0, 0);
+            isok = GetExitCodeProcess((isok) ? dup : proc->hproc, &stat);        
+            if (pfn_remotethread) {        
+                FARPROC pfnExitProc;
+                if (isok && stat == STILL_ACTIVE) {            
+                    pfnExitProc = GetProcAddress(GetModuleHandleA("KERNEL32.DLL"),
+                                                 "ExitProcess");
+                    rt = pfn_remotethread(proc->hproc, 
+                                          NULL, 0, 
+                                         (LPTHREAD_START_ROUTINE)pfnExitProc,
+                                         (PVOID)exit_code, 0, &rtid);
+                }
+            }
+            else {
+                if (isok && stat == STILL_ACTIVE)
+                    TerminateProcess(proc->hproc, exit_code);
+            }
+            if (rt) {
+                WaitForSingleObject(proc->hproc, INFINITE);
+                CloseHandle(rt);
+            }
+            if (dup)
+                CloseHandle(dup);
+            return APR_SUCCESS;
+        }
+#endif
+/* Windows 9x and CE only supports killing process, but that will do for now. */
         if (TerminateProcess(proc->hproc, signal) == 0) {
             return apr_get_os_error();
         }
