Revert "fix #46 ignore EOF"

This reverts commit 333264fdb7.
This commit is contained in:
krakjoe 2014-01-13 08:12:49 +00:00
parent 333264fdb7
commit 9add0e9f5c
2 changed files with 18 additions and 27 deletions

View file

@ -1257,8 +1257,10 @@ phpdbg_interact:
/* this must be forced */ /* this must be forced */
CG(unclean_shutdown) = 0; CG(unclean_shutdown) = 0;
} else { } else {
/* local consoles cannot disconnect, ignore EOF */ /* local client quit console */
PHPDBG_G(flags) &= ~PHPDBG_IS_DISCONNECTED; CG(unclean_shutdown) = 0;
goto phpdbg_out;
} }
} }
#endif #endif
@ -1273,7 +1275,7 @@ phpdbg_interact:
phpdbg_out: phpdbg_out:
#ifndef _WIN32 #ifndef _WIN32
if ((PHPDBG_G(flags) & PHPDBG_IS_DISCONNECTED)) { if (PHPDBG_G(flags) & PHPDBG_IS_DISCONNECTED) {
PHPDBG_G(flags) &= ~PHPDBG_IS_DISCONNECTED; PHPDBG_G(flags) &= ~PHPDBG_IS_DISCONNECTED;
goto phpdbg_interact; goto phpdbg_interact;
} }
@ -1322,7 +1324,7 @@ phpdbg_out:
if (cleaning || remote) { if (cleaning || remote) {
goto phpdbg_main; goto phpdbg_main;
} }
#ifdef ZTS #ifdef ZTS
/* bugggy */ /* bugggy */
/* tsrm_shutdown(); */ /* tsrm_shutdown(); */

View file

@ -467,43 +467,32 @@ PHPDBG_API phpdbg_input_t *phpdbg_read_input(char *buffered TSRMLS_DC) /* {{{ */
} }
if (buffered == NULL) { if (buffered == NULL) {
disconnect: #ifndef HAVE_LIBREADLINE
if (0) { char buf[PHPDBG_MAX_CMD];
if ((!(PHPDBG_G(flags) & PHPDBG_IS_REMOTE) && !phpdbg_write(phpdbg_get_prompt(TSRMLS_C))) ||
!fgets(buf, PHPDBG_MAX_CMD, PHPDBG_G(io)[PHPDBG_STDIN])) {
/* the user has gone away */
phpdbg_error("Failed to read console!");
PHPDBG_G(flags) |= (PHPDBG_IS_QUITTING|PHPDBG_IS_DISCONNECTED); PHPDBG_G(flags) |= (PHPDBG_IS_QUITTING|PHPDBG_IS_DISCONNECTED);
zend_bailout(); zend_bailout();
return NULL; return NULL;
} }
#ifndef HAVE_LIBREADLINE
char buf[PHPDBG_MAX_CMD];
if (!(PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) {
if (!phpdbg_write(phpdbg_get_prompt(TSRMLS_CC))) {
goto disconnect;
}
}
/* note: EOF is ignored */
readline:
if (!fgets(buf, PHPDBG_MAX_CMD, PHPDBG_G(io)[PHPDBG_STDIN])) {
/* the user has gone away */
if ((PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) {
goto disconnect;
} else goto readline;
}
cmd = buf; cmd = buf;
#else #else
/* note: EOF makes readline write prompt again in local console mode */
readline:
if ((PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) { if ((PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) {
char buf[PHPDBG_MAX_CMD]; char buf[PHPDBG_MAX_CMD];
if (fgets(buf, PHPDBG_MAX_CMD, PHPDBG_G(io)[PHPDBG_STDIN])) { if (fgets(buf, PHPDBG_MAX_CMD, PHPDBG_G(io)[PHPDBG_STDIN])) {
cmd = buf; cmd = buf;
} else goto disconnect; } else cmd = NULL;
} else cmd = readline(phpdbg_get_prompt(TSRMLS_C)); } else cmd = readline(phpdbg_get_prompt(TSRMLS_C));
if (!cmd) { if (!cmd) {
goto readline; /* the user has gone away */
phpdbg_error("Failed to read console!");
PHPDBG_G(flags) |= (PHPDBG_IS_QUITTING|PHPDBG_IS_DISCONNECTED);
zend_bailout();
return NULL;
} }
if (!(PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) { if (!(PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) {