Skip to content

Commit 11bdeb9

Browse files
committed
More code tweaks in proc_open.c
1 parent 870c61d commit 11bdeb9

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

ext/standard/proc_open.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,10 +1065,13 @@ PHP_FUNCTION(proc_open)
10651065
if (descriptors[i].mode == DESC_PIPE) {
10661066
close(descriptors[i].parentend);
10671067
}
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? */
10691070
perror("dup2");
1070-
if (descriptors[i].childend != descriptors[i].index)
1071+
}
1072+
if (descriptors[i].childend != descriptors[i].index) {
10711073
close(descriptors[i].childend);
1074+
}
10721075
}
10731076

10741077
if (cwd) {
@@ -1088,22 +1091,24 @@ PHP_FUNCTION(proc_open)
10881091
execl("/bin/sh", "sh", "-c", command, NULL);
10891092
}
10901093
}
1091-
_exit(127);
10921094

1095+
/* Show errors from exec!! */
1096+
_exit(127);
10931097
} else if (child < 0) {
10941098
/* failed to fork() */
10951099
close_all_descriptors(descriptors, ndesc);
10961100
php_error_docref(NULL, E_WARNING, "Fork failed - %s", strerror(errno));
10971101
goto exit_fail;
1098-
10991102
}
11001103
#else
11011104
# error You lose (configure should not have let you get here)
11021105
#endif
1106+
11031107
/* we forked/spawned and this is the parent */
11041108

11051109
pipes = zend_try_array_init(pipes);
11061110
if (!pipes) {
1111+
/* Error message? */
11071112
goto exit_fail;
11081113
}
11091114

@@ -1128,7 +1133,7 @@ PHP_FUNCTION(proc_open)
11281133
/* clean up all the child ends and then open streams on the parent
11291134
* ends, where appropriate */
11301135
for (i = 0; i < ndesc; i++) {
1131-
char *mode_string=NULL;
1136+
char *mode_string = NULL;
11321137
php_stream *stream = NULL;
11331138

11341139
close_descriptor(descriptors[i].childend);

0 commit comments

Comments
 (0)