+static void serve(struct hthead *req, int fd)
+{
+ pid_t new;
+ struct current *rec;
+
+ while((limit > 0) && (nrunning >= limit))
+ checkexit(1);
+ if((new = stdforkserve(prog, req, fd, NULL, NULL)) < 0) {
+ simpleerror(fd, 500, "Server Error", "The server appears to be overloaded.");
+ return;
+ }
+ omalloc(rec);
+ rec->pid = new;
+ rec->next = running;
+ if(running != NULL)
+ running->prev = rec;
+ running = rec;
+ nrunning++;
+}
+
+static void chldhandler(int sig)
+{
+ exited = 1;
+}
+