aboutsummaryrefslogtreecommitdiffstats
path: root/pinguctl.c
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2012-03-14 11:27:30 +0100
committerNatanael Copa <ncopa@alpinelinux.org>2012-03-14 11:27:30 +0100
commitee7897d5568535cbe03318debcb71632242f27e6 (patch)
tree0d11a1c8a74875b7d5eb90aef5dc0ce5a6d3a0d1 /pinguctl.c
parent1f9f814770fb61f41122e5408bf62b47f718e6a1 (diff)
downloadpingu-ee7897d5568535cbe03318debcb71632242f27e6.tar.bz2
pingu-ee7897d5568535cbe03318debcb71632242f27e6.tar.xz
pingu_adm: allow only one command per connection
Diffstat (limited to 'pinguctl.c')
-rw-r--r--pinguctl.c12
1 files changed, 8 insertions, 4 deletions
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[])