From 4a909d6f06b51ed618d6fc07f58a67654dee681f Mon Sep 17 00:00:00 2001 From: phk Date: Fri, 15 Feb 2008 10:36:21 +0000 Subject: [PATCH] Log everything we see on the childs stdout/stderr to syslog. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2472 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/mgt_child.c | 30 +++++++++++++++++--------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/varnish-cache/bin/varnishd/mgt_child.c b/varnish-cache/bin/varnishd/mgt_child.c index 1c2f4375..619ae810 100644 --- a/varnish-cache/bin/varnishd/mgt_child.c +++ b/varnish-cache/bin/varnishd/mgt_child.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -54,6 +55,7 @@ #include "cli_priv.h" #include "mgt_cli.h" #include "mgt_event.h" +#include "vlu.h" #include "vss.h" pid_t mgt_pid; @@ -79,28 +81,33 @@ static const char *ch_state[] = { struct evbase *mgt_evb; static struct ev *ev_poker; static struct ev *ev_listen; +static struct vlu *vlu; + +/*--------------------------------------------------------------------*/ + +static int +child_line(void *priv, const char *p) +{ + (void)priv; + + fprintf(stderr, "Child said (%d, %d): <<%s>>\n", + child_state, child_pid, p); + syslog(LOG_NOTICE, "Child (%d) said <<%s>>", child_pid, p); + return (0); +} /*--------------------------------------------------------------------*/ static int child_listener(const struct ev *e, int what) { - int i; - char buf[BUFSIZ]; (void)e; if ((what & ~EV_RD)) { ev_listen = NULL; return (1); } - i = read(child_fds[0], buf, sizeof buf - 1); - if (i <= 0) { - ev_listen = NULL; - return (1); - } - buf[i] = '\0'; - fprintf(stderr, "Child said (%d, %d): <<%s>>\n", - child_state, child_pid, buf); + VLU_Fd(child_fds[0], vlu); return (0); } @@ -222,6 +229,9 @@ start_child(void) AZ(close(child_fds[1])); child_fds[1] = -1; + vlu = VLU_New(NULL, child_line); + AN(vlu); + AZ(ev_listen); e = ev_new(); XXXAN(e); -- 2.39.5