@@ -481,6 +481,32 @@ static void set_option(zval *other_options, char *option_name, int *option_bool)
481
481
}
482
482
}
483
483
}
484
+
485
+ static void init_startup_info (STARTUPINFOW * si , struct php_proc_open_descriptor_item * descriptors , int ndesc )
486
+ {
487
+ memset (si , 0 , sizeof (STARTUPINFOW ));
488
+ si -> cb = sizeof (STARTUPINFOW );
489
+ si -> dwFlags = STARTF_USESTDHANDLES ;
490
+
491
+ si -> hStdInput = GetStdHandle (STD_INPUT_HANDLE );
492
+ si -> hStdOutput = GetStdHandle (STD_OUTPUT_HANDLE );
493
+ si -> hStdError = GetStdHandle (STD_ERROR_HANDLE );
494
+
495
+ /* redirect stdin/stdout/stderr if requested */
496
+ for (int i = 0 ; i < ndesc ; i ++ ) {
497
+ switch (descriptors [i ].index ) {
498
+ case 0 :
499
+ si -> hStdInput = descriptors [i ].childend ;
500
+ break ;
501
+ case 1 :
502
+ si -> hStdOutput = descriptors [i ].childend ;
503
+ break ;
504
+ case 2 :
505
+ si -> hStdError = descriptors [i ].childend ;
506
+ break ;
507
+ }
508
+ }
509
+ }
484
510
#endif
485
511
486
512
static struct php_proc_open_descriptor_item * alloc_descriptor_array (zval * descriptorspec )
@@ -897,29 +923,7 @@ PHP_FUNCTION(proc_open)
897
923
goto exit_fail ;
898
924
}
899
925
900
- memset (& si , 0 , sizeof (si ));
901
- si .cb = sizeof (si );
902
- si .dwFlags = STARTF_USESTDHANDLES ;
903
-
904
- si .hStdInput = GetStdHandle (STD_INPUT_HANDLE );
905
- si .hStdOutput = GetStdHandle (STD_OUTPUT_HANDLE );
906
- si .hStdError = GetStdHandle (STD_ERROR_HANDLE );
907
-
908
- /* redirect stdin/stdout/stderr if requested */
909
- for (i = 0 ; i < ndesc ; i ++ ) {
910
- switch (descriptors [i ].index ) {
911
- case 0 :
912
- si .hStdInput = descriptors [i ].childend ;
913
- break ;
914
- case 1 :
915
- si .hStdOutput = descriptors [i ].childend ;
916
- break ;
917
- case 2 :
918
- si .hStdError = descriptors [i ].childend ;
919
- break ;
920
- }
921
- }
922
-
926
+ init_startup_info (& si , descriptors , ndesc );
923
927
924
928
memset (& pi , 0 , sizeof (pi ));
925
929
0 commit comments