chiark / gitweb /
cgi-fcgi-perl: wip, check_garbage
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 22 Mar 2016 13:38:08 +0000 (13:38 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 22 Mar 2016 13:38:08 +0000 (13:38 +0000)
cprogs/cgi-fcgi-perl.c

index 58a858a..83bd962 100644 (file)
@@ -214,6 +214,23 @@ static void find_socket_path(void) {
   socket_path = m_asprintf("%s/g%s",run_base,ident);
 }  
 
+static bool check_garbage(void) {
+  struct stat sock_stab, cmd_stab;
+  int r;
+
+  r = lstat(socket_path, &sock_stab);
+  if (r) {
+    if ((errno == ENOENT))
+      return 0; /* well, no garbage then */
+    err(127,"stat socket (%s)",socket_path);
+  }
+
+  r = lstat(command, &cmd_stab);
+  if (r) err(127,"lstat command (%s)",command);
+
+  return 0;
+}
+
 int main(int argc, const char *const *argv) {
   myopt(&argv, cmdinfos);
 
@@ -223,6 +240,8 @@ int main(int argc, const char *const *argv) {
 
   find_socket_path();
 
+  check_garbage();
+
   printf(">%s<\n",socket_path);
 
   exit(0);