]> granicus.if.org Git - php/commitdiff
Fixed bug #38542 (proc_get_status() returns wrong PID on windows)
authorNuno Lopes <nlopess@php.net>
Sun, 31 Dec 2006 14:47:17 +0000 (14:47 +0000)
committerNuno Lopes <nlopess@php.net>
Sun, 31 Dec 2006 14:47:17 +0000 (14:47 +0000)
NEWS
ext/standard/proc_open.c
ext/standard/proc_open.h

diff --git a/NEWS b/NEWS
index c075c73ff3b70c3382137b5520f87bfe0764fe9e..5cd9da4a47a0e2eb4ace6c3d07388cb11a089923 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -48,6 +48,7 @@ PHP                                                                        NEWS
 - Fixed bug #39435 ('foo' instanceof bar gives invalid opcode error). (Sara)
 - Fixed bugs #39361 & #39400 (mbstring function overloading problem). (Seiji)
 - Fixed bug #38852 (XML-RPC Breaks iconv). (Hannes)
+- Fixed bug #38542 (proc_get_status() returns wrong PID on windows). (Nuno)
 - Fixed bug #37588 (COM Property propputref converts to PHP function
   and can't be accesed). (Rob)
 - Fixed bug #36392 (wrong number of decimal digits with %e specifier in
index ae145267f23299079ee2ee51e57dc3c9adcfc130..3ed72566c37bda869a047047dbe1fc92e2896ac5 100644 (file)
@@ -216,10 +216,10 @@ static void proc_open_rsrc_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
        
 #ifdef PHP_WIN32
        
-       WaitForSingleObject(proc->child, INFINITE);
-       GetExitCodeProcess(proc->child, &wstatus);
+       WaitForSingleObject(proc->childHandle, INFINITE);
+       GetExitCodeProcess(proc->childHandle, &wstatus);
        FG(pclose_ret) = wstatus;
-       CloseHandle(proc->child);
+       CloseHandle(proc->childHandle);
        
 #elif HAVE_SYS_WAIT_H
        
@@ -315,7 +315,7 @@ PHP_FUNCTION(proc_terminate)
        ZEND_FETCH_RESOURCE(proc, struct php_process_handle *, &zproc, -1, "process", le_proc_open);
        
 #ifdef PHP_WIN32
-       TerminateProcess(proc->child, 255);
+       TerminateProcess(proc->childHandle, 255);
 #else
        kill(proc->child, sig_no);
 #endif
@@ -371,7 +371,7 @@ PHP_FUNCTION(proc_get_status)
        
 #ifdef PHP_WIN32
        
-       GetExitCodeProcess(proc->child, &wstatus);
+       GetExitCodeProcess(proc->childHandle, &wstatus);
 
        running = wstatus == STILL_ACTIVE;
        exitcode == STILL_ACTIVE ? -1 : wstatus;
@@ -470,6 +470,7 @@ PHP_FUNCTION(proc_open)
        struct php_proc_open_descriptor_item descriptors[PHP_PROC_OPEN_MAX_DESCRIPTORS];
 #ifdef PHP_WIN32
        PROCESS_INFORMATION pi;
+       HANDLE childHandle;
        STARTUPINFO si;
        BOOL newprocok;
        SECURITY_ATTRIBUTES security;
@@ -747,7 +748,8 @@ PHP_FUNCTION(proc_open)
                goto exit_fail;
        }
 
-       child = pi.hProcess;
+       childHandle = pi.hProcess;
+       child       = pi.dwProcessId;
        CloseHandle(pi.hThread);
 
 #elif defined(NETWARE)
@@ -870,6 +872,9 @@ PHP_FUNCTION(proc_open)
        proc->command = command;
        proc->npipes = ndesc;
        proc->child = child;
+#ifdef PHP_WIN32
+       proc->childHandle = childHandle;
+#endif
        proc->env = env;
 
        if (pipes != NULL) {
index d1d4c1c45021afbeb650883c2bfe2f8a34c6cac4..5e07f2e5af770829d8c134913f59548f7d556cf9 100644 (file)
@@ -19,7 +19,7 @@
 
 #ifdef PHP_WIN32
 typedef HANDLE php_file_descriptor_t;
-typedef HANDLE php_process_id_t;
+typedef DWORD php_process_id_t;
 #else
 typedef int php_file_descriptor_t;
 typedef pid_t php_process_id_t;
@@ -40,6 +40,9 @@ typedef struct _php_process_env {
 
 struct php_process_handle {
        php_process_id_t        child;
+#ifdef PHP_WIN32
+       HANDLE childHandle;
+#endif
        int npipes;
        long pipes[PHP_PROC_OPEN_MAX_DESCRIPTORS];
        char *command;