chiark / gitweb /
cgi-fcgi-interp: new garbage collection approach, wip compile
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 29 Mar 2016 18:19:58 +0000 (19:19 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 29 Mar 2016 18:32:51 +0000 (19:32 +0100)
cprogs/cgi-fcgi-interp.c

index 8e126a9a70d5ae041079169f1b92498124184424..35ce536a57e90e49fa836c0698b6a8c45624f925 100644 (file)
 #include <fcntl.h>
 #include <pwd.h>
 #include <err.h>
+#include <time.h>
+#include <signal.h>
        
 #include <nettle/sha.h>
 
@@ -428,6 +430,7 @@ static void become_pgrp(void);
 static void setup_handlers(void);
 static void spawn_script(void);
 static void queue_alarm(void);
+static void await_something(void);
 
 int main(int argc, const char *const *argv) {
   const char *smashedopt, *us;
@@ -536,13 +539,13 @@ int main(int argc, const char *const *argv) {
  * and the main program has signals blocked except in sigsuspend, so
  * we don't need to worry about async-signal-safety, or errno. */
 
-static struct stab baseline_time;
+static struct stat baseline_time;
 static pid_t script_child, stage2_pgrp;
 static bool out_of_date;
 
 static void record_baseline_time(void) {
 #ifdef st_mtime
-  int r = clock_gettime(CLOCK_REALTIME, &baselime_time.st_mtim);
+  int r = clock_gettime(CLOCK_REALTIME, &baseline_time.st_mtim);
   if (r) err(127,"(stage2) clock_gettime");
 #else
   baseline_time.st_mtime = time(NULL);
@@ -616,3 +619,15 @@ static void spawn_script(void) {
 static void queue_alarm(void) {
   alarm(check_interval);
 }
+
+static void await_something(void) {
+  int r;
+  sigset_t mask;
+  sigemptyset(&mask);
+
+  for (;;) {
+    r = sigsuspend(&mask);
+    assert(r==-1);
+    if (r != EINTR) err(127,"(stage2) sigsuspend");
+  }
+}