From ee7897d5568535cbe03318debcb71632242f27e6 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Wed, 14 Mar 2012 11:27:30 +0100 Subject: pingu_adm: allow only one command per connection --- pinguctl.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'pinguctl.c') diff --git a/pinguctl.c b/pinguctl.c index 6788794..02dbe14 100644 --- a/pinguctl.c +++ b/pinguctl.c @@ -48,12 +48,16 @@ static int adm_send_cmd(int fd, const char *cmd) static int adm_recv(int fd) { char buf[1024]; - int n; + int n, total = 0; - n = recv(fd, buf, sizeof(buf), 0); - if (n > 0) + while (1) { + n = recv(fd, buf, sizeof(buf), 0); + if (n <= 0) + break; write(STDOUT_FILENO, buf, n); - return n; + total += n; + } + return total; } int main(int argc, char *argv[]) -- cgit v1.2.3