php_stream * stream = NULL;
char *p, *token, *pathdup;
long max_memory;
+ FILE *file = NULL;
if (!strncasecmp(path, "php://", 6)) {
path += 6;
fd = dup(fd);
} else {
cli_in = 1;
+ file = stdin;
}
} else {
fd = dup(STDIN_FILENO);
fd = dup(fd);
} else {
cli_out = 1;
+ file = stdout;
}
} else {
fd = dup(STDOUT_FILENO);
fd = dup(fd);
} else {
cli_err = 1;
+ file = stderr;
}
} else {
fd = dup(STDERR_FILENO);
/* failed to dup */
return NULL;
}
-
- stream = php_stream_fopen_from_fd(fd, mode, NULL);
- if (stream == NULL) {
- close(fd);
+
+ if (file) {
+ stream = php_stream_fopen_from_file(file, mode);
+ } else {
+ stream = php_stream_fopen_from_fd(fd, mode, NULL);
+ if (stream == NULL) {
+ close(fd);
+ }
}
return stream;