Commit 3dddc75c authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

More work on the debug stunt


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@676 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 9a93399c
...@@ -271,21 +271,31 @@ DebugStunt(void) ...@@ -271,21 +271,31 @@ DebugStunt(void)
break; break;
i = poll(pfd, 2, INFTIM); i = poll(pfd, 2, INFTIM);
for (k = 0; k < 2; k++) { for (k = 0; k < 2; k++) {
if (pfd[k].fd == -1)
continue;
if (pfd[k].revents == 0) if (pfd[k].revents == 0)
continue; continue;
if (pfd[k].revents != POLLIN) { if (pfd[k].revents != POLLIN) {
printf("k %d rev %d\n", k, pfd[k].revents); printf("k %d rev %d\n", k, pfd[k].revents);
AZ(close(pipes[k][0]));
AZ(close(pipes[k][1]));
pfd[k].fd = -1; pfd[k].fd = -1;
if (k == 1)
exit (0);
} }
j = read(pipes[k][0], buf, sizeof buf); j = read(pipes[k][0], buf, sizeof buf);
if (j == 0) { if (j == 0) {
printf("k %d eof\n", k); printf("k %d eof\n", k);
AZ(close(pipes[k][0]));
AZ(close(pipes[k][1]));
pfd[k].fd = -1; pfd[k].fd = -1;
} }
if (j > 0) { if (j > 0) {
i = write(pipes[k][1], buf, j); i = write(pipes[k][1], buf, j);
if (i != j) { if (i != j) {
printf("k %d write (%d %d)\n", k, 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; pfd[k].fd = -1;
} }
} }
...@@ -391,6 +401,7 @@ main(int argc, char *argv[]) ...@@ -391,6 +401,7 @@ main(int argc, char *argv[])
if (dflag == 1) if (dflag == 1)
DebugStunt(); DebugStunt();
if (dflag != 2)
daemon(dflag, dflag); daemon(dflag, dflag);
if (dflag) if (dflag)
printf("%d\n%d\n%d\n", getpid(), getsid(0), getpgrp()); printf("%d\n%d\n%d\n", getpid(), getsid(0), getpgrp());
......
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