Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit df033e3

Browse files
committed
Allow not close stream on rscr dtor in php cli sapi
1 parent 6bd0175 commit df033e3

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

‎main/php_streams.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@ struct _php_stream_wrapper {
185185
* Currently for internal use only. */
186186
#define PHP_STREAM_FLAG_SUPPRESS_ERRORS 0x100
187187

188+
/* Do not close handle except it is explicitly closed by user (e.g. fclose) */
189+
#define PHP_STREAM_FLAG_NO_RSCR_DTOR_CLOSE 0x200
190+
188191
#define PHP_STREAM_FLAG_WAS_WRITTEN 0x80000000
189192

190193
struct _php_stream {

‎main/streams/streams.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,8 @@ PHPAPI int _php_stream_free(php_stream *stream, int close_options) /* {{{ */
383383

384384
context = PHP_STREAM_CONTEXT(stream);
385385

386-
if (stream->flags & PHP_STREAM_FLAG_NO_CLOSE) {
386+
if ((stream->flags & PHP_STREAM_FLAG_NO_CLOSE) ||
387+
((stream->flags & PHP_STREAM_FLAG_NO_RSCR_DTOR_CLOSE) && (close_options & PHP_STREAM_FREE_RSRC_DTOR))) {
387388
preserve_handle = 1;
388389
}
389390

‎sapi/cli/php_cli.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -540,9 +540,9 @@ static void cli_register_file_handles(void) /* {{{ */
540540
* extensions which write to stderr or company during mshutdown/gshutdown
541541
* won't have the expected functionality.
542542
*/
543-
if (s_in) s_in->flags |= PHP_STREAM_FLAG_NO_CLOSE;
544-
if (s_out) s_out->flags |= PHP_STREAM_FLAG_NO_CLOSE;
545-
if (s_err) s_err->flags |= PHP_STREAM_FLAG_NO_CLOSE;
543+
if (s_in) s_in->flags |= PHP_STREAM_FLAG_NO_RSCR_DTOR_CLOSE;
544+
if (s_out) s_out->flags |= PHP_STREAM_FLAG_NO_RSCR_DTOR_CLOSE;
545+
if (s_err) s_err->flags |= PHP_STREAM_FLAG_NO_RSCR_DTOR_CLOSE;
546546

547547
if (s_in==NULL || s_out==NULL || s_err==NULL) {
548548
if (s_in) php_stream_close(s_in);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /