#include <ctype.h>
#include <dirent.h>
#include <time.h>
+#include <sys/wait.h>
#include <sys/signal.h>
#ifdef HAVE_CONFIG_H
char *newpath;
int rv;
- if(!el == '.') {
+ if(*el == '.') {
simpleerror(fd, 404, "Not Found", "The requested URL has no corresponding resource.");
return(1);
}
if(!*el) {
replrest(req, rest);
handledir(req, fd, path);
- return(1);
+ rv = 1;
+ goto out;
}
rv = checkentry(req, fd, path, rest, el);
simpleerror(fd, 404, "Not Found", "The requested URL has no corresponding resource.");
}
+static void chldhandler(int sig)
+{
+ pid_t pid;
+
+ do {
+ pid = waitpid(-1, NULL, WNOHANG);
+ } while(pid > 0);
+}
+
static void sighandler(int sig)
{
}
flog(LOG_ERR, "could not change directory to %s: %s", argv[optind], strerror(errno));
exit(1);
}
- signal(SIGCHLD, SIG_IGN);
+ signal(SIGCHLD, chldhandler);
signal(SIGPIPE, sighandler);
while(1) {
if((fd = recvreq(0, &req)) < 0) {