X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=blobdiff_plain;f=cprogs%2Fcgi-fcgi-interp.c;h=7aef026037b82ea70be482517f76dfe706a88a4d;hb=0858876b9824c1ad47b63d27df25b38a743cfe71;hp=2c157d218033a372c6e53c144cb091e29952ed18;hpb=84351242462d8d501402ee63536b4f56be03e1c7;p=chiark-utils.git diff --git a/cprogs/cgi-fcgi-interp.c b/cprogs/cgi-fcgi-interp.c index 2c157d2..7aef026 100644 --- a/cprogs/cgi-fcgi-interp.c +++ b/cprogs/cgi-fcgi-interp.c @@ -4,7 +4,7 @@ * #!/usr/bin/cgi-fcgi-interp [], */ /* - * cgi-fcgi-interp.[ch] - C helpers common to the whole of chiark-utils + * cgi-fcgi-interp.[ch] - Convenience wrapper for cgi-fcgi * * Copyright 2016 Ian Jackson * Copyright 1982,1986,1993 The Regents of the University of California @@ -604,7 +604,6 @@ int main(int argc, const char *const *argv) { script = *argv++; if (!script) badusage("need script argument"); - if (*argv) badusage("too many arguments"); if (!stage2) { @@ -789,12 +788,19 @@ static void errpipe_readable(void) { static char buf[1024]; static int pending; + /* %: does not contain newlines + * _: empty (garbage) + */ + + /* %%%%%%%%%%%__________________ */ + /* ^ pending */ + for (;;) { int avail = sizeof(buf) - pending; ssize_t got = read(errpipe, buf+pending, avail); if (got==-1) { if (errno==EINTR) continue; - else if (errno==EWOULDBLOCK || errno==EAGAIN) /*ok*/; + else if (errno==EWOULDBLOCK || errno==EAGAIN) return; else diee("(stage2) errpipe read"); got = 0; } else if (got==0) { @@ -819,6 +825,7 @@ static void errpipe_readable(void) { } syslog(LOG_ERR,"stderr: %.*s", printupto-eaten, buf+eaten); eaten += eat; + scanned = eaten; } pending -= eaten; memmove(buf, buf+eaten, pending);