Commit b530ed43 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp
parents 1ebd8615 7058d471
...@@ -55,9 +55,9 @@ SVNID("$Id$") ...@@ -55,9 +55,9 @@ SVNID("$Id$")
do { \ do { \
rl_callback_handler_remove(); \ rl_callback_handler_remove(); \
exit(status); \ exit(status); \
} while (0); } while (0)
#else #else
#define RL_EXIT(status) exit(status); #define RL_EXIT(status) exit(status)
#endif #endif
static double timeout = 5; static double timeout = 5;
...@@ -193,7 +193,9 @@ pass(int sock) ...@@ -193,7 +193,9 @@ pass(int sock)
{ {
struct pollfd fds[2]; struct pollfd fds[2];
char buf[1024]; char buf[1024];
int i, n, m; int i, n;
char *answer = NULL;
unsigned u, status;
#ifdef HAVE_LIBEDIT #ifdef HAVE_LIBEDIT
_line_sock = sock; _line_sock = sock;
...@@ -214,20 +216,24 @@ pass(int sock) ...@@ -214,20 +216,24 @@ pass(int sock)
i = poll(fds, 2, -1); i = poll(fds, 2, -1);
assert(i > 0); assert(i > 0);
if (fds[0].revents & POLLIN) { if (fds[0].revents & POLLIN) {
n = read(fds[0].fd, buf, sizeof buf); /* Get rid of the prompt, kinda hackish */
if (n == 0) u = write(1, "\r \r", 13);
u = cli_readres(fds[0].fd, &status, &answer, timeout);
if (u) {
if (status == CLIS_COMMS)
RL_EXIT(0); RL_EXIT(0);
if (n < 0) { if (answer)
perror("Read error reading CLI socket"); fprintf(stderr, "%s\n", answer);
RL_EXIT(1); RL_EXIT(1);
} }
assert(n > 0);
/* Get rid of the prompt, kinda hackish */ sprintf(buf, "%u\n", status);
write(1, "\r \r", 13); u = write(1, buf, strlen(buf));
m = write(1, buf, n); if (answer) {
if (n != m) { u = write(1, answer, strlen(answer));
perror("Write error writing stdout"); u = write(1, "\n", 1);
RL_EXIT(1); free(answer);
answer = NULL;
} }
#ifdef HAVE_LIBEDIT #ifdef HAVE_LIBEDIT
rl_forced_update_display(); rl_forced_update_display();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment