From e0ec4f813a8d3627f3738f0247ed8a46c97b9e39 Mon Sep 17 00:00:00 2001 From: phk Date: Thu, 3 Aug 2006 11:45:23 +0000 Subject: [PATCH] Make the pipe-stunt debug process smarter. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@621 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/varnishd.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/varnish-cache/bin/varnishd/varnishd.c b/varnish-cache/bin/varnishd/varnishd.c index 8ea8a2c0..a7d5e407 100644 --- a/varnish-cache/bin/varnishd/varnishd.c +++ b/varnish-cache/bin/varnishd/varnishd.c @@ -556,6 +556,7 @@ DebugStunt(void) pfd[1].fd = pipes[1][0]; pfd[1].events = POLLIN; + signal(SIGPIPE, SIG_IGN); signal(SIGINT, DebugSigPass); i = read(pipes[1][0], buf, sizeof buf - 1); buf[i] = '\0'; @@ -569,15 +570,17 @@ DebugStunt(void) while (1) { i = poll(pfd, 2, INFTIM); for (k = 0; k < 2; k++) { - if (pfd[k].revents) { - j = read(pipes[k][0], buf, sizeof buf); - if (j == 0) - exit (0); - if (j > 0) { - i = write(pipes[k][1], buf, j); - if (i != j) - err(1, "i = %d j = %d\n", i, j); - } + if (pfd[k].revents == 0) + continue; + if (pfd[k].revents != POLLIN) + exit (2); + j = read(pipes[k][0], buf, sizeof buf); + if (j == 0) + exit (0); + if (j > 0) { + i = write(pipes[k][1], buf, j); + if (i != j) + err(1, "i = %d j = %d\n", i, j); } } } -- 2.39.5