@@ -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
/* }}} */
@@ -561,7 +556,6 @@ static int set_proc_descriptor_to_blackhole(struct php_proc_open_descriptor_item
561
556
return FAILURE ;
562
557
}
563
558
#endif
564
- desc -> mode = DESC_FILE ;
565
559
return SUCCESS ;
566
560
}
567
561
@@ -574,7 +568,7 @@ static int set_proc_descriptor_to_pipe(struct php_proc_open_descriptor_item *des
574
568
return FAILURE ;
575
569
}
576
570
577
- desc -> mode = DESC_PIPE ;
571
+ desc -> is_pipe = 1 ;
578
572
579
573
if (strncmp (Z_STRVAL_P (zmode ), "w" , 1 ) != 0 ) {
580
574
desc -> parentend = newpipe [1 ];
@@ -613,8 +607,6 @@ static int set_proc_descriptor_to_file(struct php_proc_open_descriptor_item *des
613
607
return FAILURE ;
614
608
}
615
609
616
- desc -> mode = DESC_FILE ;
617
-
618
610
#ifdef PHP_WIN32
619
611
desc -> childend = dup_fd_as_handle ((int )fd );
620
612
_close ((int )fd );
@@ -799,8 +791,6 @@ PHP_FUNCTION(proc_open)
799
791
goto exit_fail ;
800
792
}
801
793
#endif
802
- descriptors [ndesc ].mode = DESC_FILE ;
803
-
804
794
} else if (Z_TYPE_P (descitem ) != IS_ARRAY ) {
805
795
zend_argument_value_error (2 , "must only contain arrays and File-Handles" );
806
796
goto exit_fail ;
@@ -913,7 +903,6 @@ PHP_FUNCTION(proc_open)
913
903
goto exit_fail ;
914
904
}
915
905
#endif
916
- descriptors [ndesc ].mode = DESC_REDIRECT ;
917
906
} else if (strcmp (Z_STRVAL_P (ztype ), "null" ) == 0 ) {
918
907
if (set_proc_descriptor_to_blackhole (& descriptors [ndesc ]) == FAILURE ) {
919
908
goto exit_fail ;
@@ -936,7 +925,7 @@ PHP_FUNCTION(proc_open)
936
925
goto exit_fail ;
937
926
}
938
927
}
939
- descriptors [ndesc ].mode = DESC_PIPE ;
928
+ descriptors [ndesc ].is_pipe = 1 ;
940
929
descriptors [ndesc ].childend = dup (slave_pty );
941
930
descriptors [ndesc ].parentend = dup (dev_ptmx );
942
931
descriptors [ndesc ].mode_flags = O_RDWR ;
@@ -1062,7 +1051,7 @@ PHP_FUNCTION(proc_open)
1062
1051
* dup new descriptors into required descriptors and close the original
1063
1052
* cruft */
1064
1053
for (i = 0 ; i < ndesc ; i ++ ) {
1065
- if (descriptors [i ].mode == DESC_PIPE ) {
1054
+ if (descriptors [i ].is_pipe ) {
1066
1055
close (descriptors [i ].parentend );
1067
1056
}
1068
1057
if (dup2 (descriptors [i ].childend , descriptors [i ].index ) < 0 ) {
@@ -1138,7 +1127,7 @@ PHP_FUNCTION(proc_open)
1138
1127
1139
1128
close_descriptor (descriptors [i ].childend );
1140
1129
1141
- if (descriptors [i ].mode == DESC_PIPE ) {
1130
+ if (descriptors [i ].is_pipe ) {
1142
1131
switch (descriptors [i ].mode_flags ) {
1143
1132
#ifdef PHP_WIN32
1144
1133
case O_WRONLY |O_BINARY :
0 commit comments