2 ashd - A Sane HTTP Daemon
3 Copyright (C) 2008 Fredrik Tolf <fredrik@dolda2000.com>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
38 static void serve(struct hthead *req, int fd)
40 if(stdforkserve(prog, req, fd, NULL, NULL) < 0)
41 simpleerror(fd, 500, "Server Error", "The server appears to be overloaded.");
44 static void chldhandler(int sig)
49 while((pid = waitpid(-1, &st, WNOHANG)) > 0) {
51 flog(LOG_WARNING, "child process %i dumped core", pid);
55 static void usage(FILE *out)
57 fprintf(out, "usage: httrcall [-h] PROGRAM [ARGS...]\n");
60 int main(int argc, char **argv)
66 while((c = getopt(argc, argv, "+h")) >= 0) {
76 if(argc < optind - 1) {
81 signal(SIGCHLD, chldhandler);
83 if((fd = recvreq(0, &req)) < 0) {
87 flog(LOG_ERR, "recvreq: %s", strerror(errno));