Skip to content

Commit 9add0e9

Browse files
committed
Revert "fix #46 ignore EOF"
This reverts commit 333264f.
1 parent 333264f commit 9add0e9

File tree

2 files changed

+18
-27
lines changed

2 files changed

+18
-27
lines changed

phpdbg.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -1257,8 +1257,10 @@ int main(int argc, char **argv) /* {{{ */
12571257
/* this must be forced */
12581258
CG(unclean_shutdown) = 0;
12591259
} else {
1260-
/* local consoles cannot disconnect, ignore EOF */
1261-
PHPDBG_G(flags) &= ~PHPDBG_IS_DISCONNECTED;
1260+
/* local client quit console */
1261+
CG(unclean_shutdown) = 0;
1262+
1263+
goto phpdbg_out;
12621264
}
12631265
}
12641266
#endif
@@ -1273,7 +1275,7 @@ int main(int argc, char **argv) /* {{{ */
12731275

12741276
phpdbg_out:
12751277
#ifndef _WIN32
1276-
if ((PHPDBG_G(flags) & PHPDBG_IS_DISCONNECTED)) {
1278+
if (PHPDBG_G(flags) & PHPDBG_IS_DISCONNECTED) {
12771279
PHPDBG_G(flags) &= ~PHPDBG_IS_DISCONNECTED;
12781280
goto phpdbg_interact;
12791281
}
@@ -1322,7 +1324,7 @@ int main(int argc, char **argv) /* {{{ */
13221324
if (cleaning || remote) {
13231325
goto phpdbg_main;
13241326
}
1325-
1327+
13261328
#ifdef ZTS
13271329
/* bugggy */
13281330
/* tsrm_shutdown(); */

phpdbg_cmd.c

+12-23
Original file line numberDiff line numberDiff line change
@@ -467,43 +467,32 @@ PHPDBG_API phpdbg_input_t *phpdbg_read_input(char *buffered TSRMLS_DC) /* {{{ */
467467
}
468468

469469
if (buffered == NULL) {
470-
disconnect:
471-
if (0) {
472-
PHPDBG_G(flags) |= (PHPDBG_IS_QUITTING|PHPDBG_IS_DISCONNECTED);
473-
zend_bailout();
474-
return NULL;
475-
}
476-
477470
#ifndef HAVE_LIBREADLINE
478471
char buf[PHPDBG_MAX_CMD];
479-
if (!(PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) {
480-
if (!phpdbg_write(phpdbg_get_prompt(TSRMLS_CC))) {
481-
goto disconnect;
482-
}
483-
}
484-
485-
/* note: EOF is ignored */
486-
readline:
487-
if (!fgets(buf, PHPDBG_MAX_CMD, PHPDBG_G(io)[PHPDBG_STDIN])) {
472+
if ((!(PHPDBG_G(flags) & PHPDBG_IS_REMOTE) && !phpdbg_write(phpdbg_get_prompt(TSRMLS_C))) ||
473+
!fgets(buf, PHPDBG_MAX_CMD, PHPDBG_G(io)[PHPDBG_STDIN])) {
488474
/* the user has gone away */
489-
if ((PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) {
490-
goto disconnect;
491-
} else goto readline;
475+
phpdbg_error("Failed to read console!");
476+
PHPDBG_G(flags) |= (PHPDBG_IS_QUITTING|PHPDBG_IS_DISCONNECTED);
477+
zend_bailout();
478+
return NULL;
492479
}
493480

494481
cmd = buf;
495482
#else
496-
/* note: EOF makes readline write prompt again in local console mode */
497-
readline:
498483
if ((PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) {
499484
char buf[PHPDBG_MAX_CMD];
500485
if (fgets(buf, PHPDBG_MAX_CMD, PHPDBG_G(io)[PHPDBG_STDIN])) {
501486
cmd = buf;
502-
} else goto disconnect;
487+
} else cmd = NULL;
503488
} else cmd = readline(phpdbg_get_prompt(TSRMLS_C));
504489

505490
if (!cmd) {
506-
goto readline;
491+
/* the user has gone away */
492+
phpdbg_error("Failed to read console!");
493+
PHPDBG_G(flags) |= (PHPDBG_IS_QUITTING|PHPDBG_IS_DISCONNECTED);
494+
zend_bailout();
495+
return NULL;
507496
}
508497

509498
if (!(PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) {

0 commit comments

Comments
 (0)