From: phk Date: Sat, 5 Aug 2006 16:31:24 +0000 (+0000) Subject: More work on the debug stunt X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0f44bd864a7b2eccb171721791b8bc70d248d6e2;p=varnish More work on the debug stunt git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@676 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/varnishd.c b/varnish-cache/bin/varnishd/varnishd.c index d6706e25..8f419784 100644 --- a/varnish-cache/bin/varnishd/varnishd.c +++ b/varnish-cache/bin/varnishd/varnishd.c @@ -271,21 +271,31 @@ DebugStunt(void) break; i = poll(pfd, 2, INFTIM); for (k = 0; k < 2; k++) { + if (pfd[k].fd == -1) + continue; if (pfd[k].revents == 0) continue; if (pfd[k].revents != POLLIN) { printf("k %d rev %d\n", k, pfd[k].revents); + AZ(close(pipes[k][0])); + AZ(close(pipes[k][1])); pfd[k].fd = -1; + if (k == 1) + exit (0); } j = read(pipes[k][0], buf, sizeof buf); if (j == 0) { printf("k %d eof\n", k); + AZ(close(pipes[k][0])); + AZ(close(pipes[k][1])); pfd[k].fd = -1; } if (j > 0) { i = write(pipes[k][1], buf, j); if (i != j) { printf("k %d write (%d %d)\n", k, i, j); + AZ(close(pipes[k][0])); + AZ(close(pipes[k][1])); pfd[k].fd = -1; } } @@ -391,7 +401,8 @@ main(int argc, char *argv[]) if (dflag == 1) DebugStunt(); - daemon(dflag, dflag); + if (dflag != 2) + daemon(dflag, dflag); if (dflag) printf("%d\n%d\n%d\n", getpid(), getsid(0), getpgrp());