@@ -34,6 +34,7 @@ class Process
34
34
private $ status ;
35
35
private $ stdout ;
36
36
private $ stderr ;
37
+ private $ enhanceWindowsCompatibility = true ;
37
38
38
39
/**
39
40
* Exit codes translation table.
@@ -159,7 +160,13 @@ public function run($callback = null)
159
160
160
161
$ descriptors = array (array ('pipe ' , 'r ' ), array ('pipe ' , 'w ' ), array ('pipe ' , 'w ' ));
161
162
162
- $ process = proc_open ($ this ->commandline , $ descriptors , $ pipes , $ this ->cwd , $ this ->env , $ this ->options );
163
+ $ commandline = $ this ->commandline ;
164
+
165
+ if (defined ('PHP_WINDOWS_VERSION_BUILD ' ) && $ this ->enhanceWindowsCompatibility ) {
166
+ $ commandline = 'cmd /V:ON /E:ON /C " ' .$ commandline .'" ' ;
167
+ }
168
+
169
+ $ process = proc_open ($ commandline , $ descriptors , $ pipes , $ this ->cwd , $ this ->env , $ this ->options );
163
170
164
171
if (!is_resource ($ process )) {
165
172
throw new \RuntimeException ('Unable to launch a new process. ' );
@@ -431,4 +438,15 @@ public function setOptions(array $options)
431
438
{
432
439
$ this ->options = $ options ;
433
440
}
441
+
442
+ public function getEnhanceWindowsCompatibility ()
443
+ {
444
+ return $ this ->enhanceWindowsCompatibility ;
445
+ }
446
+
447
+ public function setEnhanceWindowsCompatibility ($ enhance )
448
+ {
449
+ $ this ->enhanceWindowsCompatibility = (Boolean ) $ enhance ;
450
+ }
451
+
434
452
}
0 commit comments