We need to clear stdin errors otherwise it returns EOF forever after
CTRL+D.
Reported-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
if (is_interactive)
rl_callback_handler_install(prompt, reply_linehandler);
#endif
+ errno = 0;
reply_running = 1;
do {
int rc;
if (!*buf) {
DBG(ASK, ul_debug("cancel by CTRL+D"));
ret = -ECANCELED;
+ clearerr(stdin);
goto done;
}
if (sz && *(buf + sz - 1) == '\n')
*(buf + sz - 1) = '\0';
- DBG(ASK, ul_debug("user's reply: >>>%s<<<", buf));
done:
#ifdef HAVE_LIBREADLINE
if (is_interactive)
rl_callback_handler_remove();
#endif
sigaction(SIGINT, &oldact, NULL);
+ DBG(ASK, ul_debug("user's reply: >>>%s<<< [rc=%d]", buf, ret));
return ret;
}