@@ -1065,10 +1065,13 @@ PHP_FUNCTION(proc_open)
1065
1065
if (descriptors [i ].mode == DESC_PIPE ) {
1066
1066
close (descriptors [i ].parentend );
1067
1067
}
1068
- if (dup2 (descriptors [i ].childend , descriptors [i ].index ) < 0 )
1068
+ if (dup2 (descriptors [i ].childend , descriptors [i ].index ) < 0 ) {
1069
+ /* better way to report any problems? */
1069
1070
perror ("dup2" );
1070
- if (descriptors [i ].childend != descriptors [i ].index )
1071
+ }
1072
+ if (descriptors [i ].childend != descriptors [i ].index ) {
1071
1073
close (descriptors [i ].childend );
1074
+ }
1072
1075
}
1073
1076
1074
1077
if (cwd ) {
@@ -1088,22 +1091,24 @@ PHP_FUNCTION(proc_open)
1088
1091
execl ("/bin/sh" , "sh" , "-c" , command , NULL );
1089
1092
}
1090
1093
}
1091
- _exit (127 );
1092
1094
1095
+ /* Show errors from exec!! */
1096
+ _exit (127 );
1093
1097
} else if (child < 0 ) {
1094
1098
/* failed to fork() */
1095
1099
close_all_descriptors (descriptors , ndesc );
1096
1100
php_error_docref (NULL , E_WARNING , "Fork failed - %s" , strerror (errno ));
1097
1101
goto exit_fail ;
1098
-
1099
1102
}
1100
1103
#else
1101
1104
# error You lose (configure should not have let you get here)
1102
1105
#endif
1106
+
1103
1107
/* we forked/spawned and this is the parent */
1104
1108
1105
1109
pipes = zend_try_array_init (pipes );
1106
1110
if (!pipes ) {
1111
+ /* Error message? */
1107
1112
goto exit_fail ;
1108
1113
}
1109
1114
@@ -1128,7 +1133,7 @@ PHP_FUNCTION(proc_open)
1128
1133
/* clean up all the child ends and then open streams on the parent
1129
1134
* ends, where appropriate */
1130
1135
for (i = 0 ; i < ndesc ; i ++ ) {
1131
- char * mode_string = NULL ;
1136
+ char * mode_string = NULL ;
1132
1137
php_stream * stream = NULL ;
1133
1138
1134
1139
close_descriptor (descriptors [i ].childend );
0 commit comments