#include <ctype.h>
#include <signal.h>
#include <sys/poll.h>
+#include <sys/wait.h>
#ifdef HAVE_CONFIG_H
#include <config.h>
static pid_t forkchild(int inpath, char *prog, char *file, char *method, char *url, char *rest, int *infd, int *outfd)
{
- int i;
char *qp, **env, *name;
int inp[2], outp[2];
pid_t pid;
exit(1);
}
if(pid == 0) {
- close(inp[1]);
- close(outp[0]);
dup2(inp[0], 0);
dup2(outp[1], 1);
- for(i = 3; i < FD_SETSIZE; i++)
- close(i);
+ close(inp[0]);
+ close(inp[1]);
+ close(outp[0]);
+ close(outp[1]);
if((qp = strchr(url, '?')) != NULL)
*(qp++) = 0;
putenv(sprintf2("SERVER_SOFTWARE=ashd/%s", VERSION));
FILE *in, *out;
char **headers;
pid_t child;
+ int estat;
environ = envp;
signal(SIGPIPE, SIG_IGN);
printf("\n");
if(passdata(out, stdout))
kill(child, SIGINT);
- return(0);
+ if(waitpid(child, &estat, 0) == child) {
+ if(WCOREDUMP(estat))
+ flog(LOG_WARNING, "CGI handler `%s' dumped core", prog);
+ if(WIFEXITED(estat) && !WEXITSTATUS(estat))
+ return(0);
+ else
+ return(1);
+ }
+ flog(LOG_WARNING, "could not wait for CGI handler: %s", strerror(errno));
+ return(1);
}