--- libaitcli/src/aitcli.c 2013/11/20 16:04:42 1.9.2.1 +++ libaitcli/src/aitcli.c 2013/11/22 14:46:01 1.11.2.2 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: aitcli.c,v 1.9.2.1 2013/11/20 16:04:42 misho Exp $ +* $Id: aitcli.c,v 1.11.2.2 2013/11/22 14:46:01 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -1280,7 +1280,8 @@ cliReadLine(linebuffer_t * __restrict cli_buffer, int if (!cli_buffer) { cli_SetErr(EINVAL, "Invalid input parameters ..."); return NULL; - } + } else if (timeout > 0) + timeout *= 1000; /* convert from sec to ms */ memset(&fds, 0, sizeof fds); fds.fd = cli_buffer->line_in; @@ -1289,8 +1290,15 @@ cliReadLine(linebuffer_t * __restrict cli_buffer, int printfCR(cli_buffer, 1); while (42) { if ((ret = poll(&fds, 1, timeout)) < 1) { - LOGERR; - return ret ? str : ""; + if (!ret) { + cli_buffer->line_kill = 1; + if (str) { + e_free(str); + str = NULL; + } + } else + LOGERR; + return str; } memset(buf, 0, sizeof buf); @@ -1525,7 +1533,7 @@ cliLoop(linebuffer_t * __restrict cli_buffer, const ch cli_freeLine(cli_buffer); cli_resetHistory(cli_buffer); e_free(line); - } while (ret < 1); + } while (cli_buffer->line_kill || ret < 1); cli_saveHistory(cli_buffer, csHistFile, HISTORY_LINES); return ret;