wez             Fri Dec  5 08:45:01 2003 EDT

  Modified files:              
    /php-src/ext/standard       proc_open.c 
    /php-src    run-tests.php 
  Log:
  Add optional array argument to proc_open() to specify additional
  options for the child process.
  The first option is "suppress_errors" which will disable any
  dialog boxes that arise from missing DLL's and suppress the
  GPF dialog.
  Use this new feature in the test suite, so that crashing tests don't block the test 
run; useful for un-attended execution.
  
Index: php-src/ext/standard/proc_open.c
diff -u php-src/ext/standard/proc_open.c:1.16 php-src/ext/standard/proc_open.c:1.17
--- php-src/ext/standard/proc_open.c:1.16       Thu Aug 28 12:49:57 2003
+++ php-src/ext/standard/proc_open.c    Fri Dec  5 08:45:00 2003
@@ -15,7 +15,7 @@
    | Author: Wez Furlong <[EMAIL PROTECTED]>                           |
    +----------------------------------------------------------------------+
  */
-/* $Id: proc_open.c,v 1.16 2003/08/28 16:49:57 sas Exp $ */
+/* $Id: proc_open.c,v 1.17 2003/12/05 13:45:00 wez Exp $ */
 
 #include <stdio.h>
 #include "php.h"
@@ -444,16 +444,16 @@
 };
 /* }}} */
 
-/* {{{ proto resource proc_open(string command, array descriptorspec, array &pipes [, 
string cwd [, array env]])
+/* {{{ proto resource proc_open(string command, array descriptorspec, array &pipes [, 
string cwd [, array env] [, array other_options]])
    Run a process with more control over it's file descriptors */
 PHP_FUNCTION(proc_open)
 {
-
        char *command, *cwd=NULL;
        long command_len, cwd_len;
        zval *descriptorspec;
        zval *pipes;
        zval *environment = NULL;
+       zval *other_options = NULL;
        php_process_env_t env;
        int ndesc = 0;
        int i;
@@ -466,13 +466,16 @@
        BOOL newprocok;
        SECURITY_ATTRIBUTES security;
        char *command_with_cmd;
+       UINT old_error_mode;
+       int suppress_errors = 0;
 #endif
        php_process_id_t child;
        struct php_process_handle *proc;
        int is_persistent = 0; /* TODO: ensure that persistent procs will work */
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "saz|s!a!", &command,
-                               &command_len, &descriptorspec, &pipes, &cwd, &cwd_len, 
&environment) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "saz|s!a!a!", &command,
+                               &command_len, &descriptorspec, &pipes, &cwd, &cwd_len, 
&environment,
+                               &other_options) == FAILURE) {
                RETURN_FALSE;
        }
 
@@ -480,6 +483,15 @@
                RETURN_FALSE;
        }
 
+       if (other_options) {
+               zval **item;
+               if (SUCCESS == zend_hash_find(Z_ARRVAL_P(other_options), 
"suppress_errors", sizeof("suppress_errors"), (void**)&item)) {
+                       if (Z_TYPE_PP(item) == IS_BOOL && Z_BVAL_PP(item)) {
+                               suppress_errors = 1;
+                       }
+               }       
+       }
+       
        command_len = strlen(command);
 
        if (environment) {
@@ -669,7 +681,17 @@
        
        command_with_cmd = emalloc(command_len + sizeof(COMSPEC_9X) + 1 + sizeof(" /c 
"));
        sprintf(command_with_cmd, "%s /c %s", GetVersion() < 0x80000000 ? COMSPEC_NT : 
COMSPEC_9X, command);
+
+       if (suppress_errors) {
+               old_error_mode = 
SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOGPFAULTERRORBOX);
+       }
+       
        newprocok = CreateProcess(NULL, command_with_cmd, &security, &security, TRUE, 
NORMAL_PRIORITY_CLASS, env.envp, cwd, &si, &pi);
+
+       if (suppress_errors) {
+               SetErrorMode(old_error_mode);
+       }
+       
        efree(command_with_cmd);
 
        if (FALSE == newprocok) {
Index: php-src/run-tests.php
diff -u php-src/run-tests.php:1.180 php-src/run-tests.php:1.181
--- php-src/run-tests.php:1.180 Sun Nov 30 08:57:15 2003
+++ php-src/run-tests.php       Fri Dec  5 08:45:00 2003
@@ -117,6 +117,7 @@
                putenv("TEST_PHP_EXECUTABLE=$php");
        }
 }
+
 if (empty($php) || !file_exists($php)) {
        error("environment variable TEST_PHP_EXECUTABLE must be set to specify PHP 
executable!");
 }
@@ -588,7 +589,7 @@
                0 => array('pipe', 'r'),
                1 => array('pipe', 'w'),
                2 => array('pipe', 'w')
-               ), $pipes);
+               ), $pipes, null, null, array("suppress_errors" => true));
 
        if (!$proc)
                return false;

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to