@@ -385,15 +385,10 @@ static inline HANDLE dup_fd_as_handle(int fd)
385
385
# define close_descriptor (fd ) close(fd)
386
386
#endif
387
387
388
- /* possible values of php_proc_open_descriptor_item.mode */
389
- #define DESC_PIPE 1
390
- #define DESC_FILE 2
391
- #define DESC_REDIRECT 3
392
-
393
388
struct php_proc_open_descriptor_item {
394
389
int index ; /* desired FD number in child process */
390
+ int is_pipe ;
395
391
php_file_descriptor_t parentend , childend ; /* FDs for pipes in parent/child */
396
- int mode ; /* mode for proc_open code */
397
392
int mode_flags ; /* mode flags for opening FDs */
398
393
};
399
394
/* }}} */
@@ -562,7 +557,6 @@ static int set_proc_descriptor_to_blackhole(struct php_proc_open_descriptor_item
562
557
return FAILURE ;
563
558
}
564
559
#endif
565
- desc -> mode = DESC_FILE ;
566
560
return SUCCESS ;
567
561
}
568
562
@@ -575,7 +569,7 @@ static int set_proc_descriptor_to_pipe(struct php_proc_open_descriptor_item *des
575
569
return FAILURE ;
576
570
}
577
571
578
- desc -> mode = DESC_PIPE ;
572
+ desc -> is_pipe = 1 ;
579
573
580
574
if (strncmp (Z_STRVAL_P (zmode ), "w" , 1 ) != 0 ) {
581
575
desc -> parentend = newpipe [1 ];
@@ -614,8 +608,6 @@ static int set_proc_descriptor_to_file(struct php_proc_open_descriptor_item *des
614
608
return FAILURE ;
615
609
}
616
610
617
- desc -> mode = DESC_FILE ;
618
-
619
611
#ifdef PHP_WIN32
620
612
desc -> childend = dup_fd_as_handle ((int )fd );
621
613
_close ((int )fd );
@@ -800,8 +792,6 @@ PHP_FUNCTION(proc_open)
800
792
goto exit_fail ;
801
793
}
802
794
#endif
803
- descriptors [ndesc ].mode = DESC_FILE ;
804
-
805
795
} else if (Z_TYPE_P (descitem ) != IS_ARRAY ) {
806
796
zend_argument_value_error (2 , "must only contain arrays and File-Handles" );
807
797
goto exit_fail ;
@@ -914,7 +904,6 @@ PHP_FUNCTION(proc_open)
914
904
goto exit_fail ;
915
905
}
916
906
#endif
917
- descriptors [ndesc ].mode = DESC_REDIRECT ;
918
907
} else if (strcmp (Z_STRVAL_P (ztype ), "null" ) == 0 ) {
919
908
if (set_proc_descriptor_to_blackhole (& descriptors [ndesc ]) == FAILURE ) {
920
909
goto exit_fail ;
@@ -937,7 +926,7 @@ PHP_FUNCTION(proc_open)
937
926
goto exit_fail ;
938
927
}
939
928
}
940
- descriptors [ndesc ].mode = DESC_PIPE ;
929
+ descriptors [ndesc ].is_pipe = 1 ;
941
930
descriptors [ndesc ].childend = dup (slave_pty );
942
931
descriptors [ndesc ].parentend = dup (dev_ptmx );
943
932
descriptors [ndesc ].mode_flags = O_RDWR ;
@@ -1061,7 +1050,7 @@ PHP_FUNCTION(proc_open)
1061
1050
* dup new descriptors into required descriptors and close the original
1062
1051
* cruft */
1063
1052
for (i = 0 ; i < ndesc ; i ++ ) {
1064
- if (descriptors [i ].mode == DESC_PIPE ) {
1053
+ if (descriptors [i ].is_pipe ) {
1065
1054
close (descriptors [i ].parentend );
1066
1055
}
1067
1056
if (dup2 (descriptors [i ].childend , descriptors [i ].index ) < 0 ) {
@@ -1135,7 +1124,7 @@ PHP_FUNCTION(proc_open)
1135
1124
1136
1125
close_descriptor (descriptors [i ].childend );
1137
1126
1138
- if (descriptors [i ].mode == DESC_PIPE ) {
1127
+ if (descriptors [i ].is_pipe ) {
1139
1128
switch (descriptors [i ].mode_flags ) {
1140
1129
#ifdef PHP_WIN32
1141
1130
case O_WRONLY |O_BINARY :
0 commit comments