summaryrefslogtreecommitdiff
path: root/fcgiwrap.c
diff options
context:
space:
mode:
authorJoseph Gooch <mrwizard@k12system.com>2011-12-07 18:45:18 -0500
committerJoe Gooch <mrwizard@k12system.com>2011-12-08 15:24:13 -0500
commit1394f56db22613ac43ceed83c5d039226b43f70d (patch)
treeb1092336032b92e40d6f34e1dae201d11d9bdcad /fcgiwrap.c
parent58ec209478f50b2048cff5805a4ff4176f3c230b (diff)
downloadfcgiwrap-1394f56db22613ac43ceed83c5d039226b43f70d.tar.xz
fcgiwrap-1394f56db22613ac43ceed83c5d039226b43f70d.zip
Create -f option to allow sending stderr to fcgi logs
Diffstat (limited to 'fcgiwrap.c')
-rw-r--r--fcgiwrap.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/fcgiwrap.c b/fcgiwrap.c
index 3e44a50..f0bf6d5 100644
--- a/fcgiwrap.c
+++ b/fcgiwrap.c
@@ -76,6 +76,8 @@ static const char * blacklisted_env_vars[] = {
NULL,
};
+static int stderr_to_fastcgi = 0;
+
#define FCGI_BUF_SIZE 4096
@@ -326,7 +328,10 @@ static void fcgi_pass(struct fcgi_context *fc)
}
}
if (fc->fd_stderr >= 0 && FD_ISSET(fc->fd_stderr, &rset)) {
- err = fcgi_pass_raw_fd(&fc->fd_stderr, 2, buf, sizeof(buf));
+ if (stderr_to_fastcgi)
+ err = fcgi_pass_fd(fc, &fc->fd_stderr, FCGI_stderr, buf, sizeof(buf));
+ else
+ err = fcgi_pass_raw_fd(&fc->fd_stderr, 2, buf, sizeof(buf));
if (err) {
fcgi_finish(fc, err);
return;
@@ -739,8 +744,11 @@ int main(int argc, char **argv)
char *socket_url = NULL;
int c;
- while ((c = getopt(argc, argv, "c:hs:")) != -1) {
+ while ((c = getopt(argc, argv, "c:hfs:")) != -1) {
switch (c) {
+ case 'f':
+ stderr_to_fastcgi++;
+ break;
case 'h':
printf("Usage: %s [OPTION]\nInvokes CGI scripts as FCGI.\n\n"
PACKAGE_NAME" version "PACKAGE_VERSION"\n\n"