Roxen.git / server / base_server / roxen.pike

version» Context lines:

Roxen.git/server/base_server/roxen.pike:1:   // This file is part of Roxen WebServer.   // Copyright © 1996 - 2009, Roxen IS.   //   // The Roxen WebServer main program.   //   // Per Hedbor, Henrik Grubbström, Pontus Hagland, David Hedbor and others.   // ABS and suicide systems contributed freely by Francesco Chemolli    - constant cvs_version="$Id: roxen.pike,v 1.1121 2012/07/13 10:00:58 jonasw Exp $"; + constant cvs_version="$Id: roxen.pike,v 1.1122 2012/09/20 12:05:33 grubba Exp $";      //! @appears roxen   //!   //! The Roxen WebServer main program.      // The argument cache. Used by the image cache.   ArgCache argcache;      // Some headerfiles   #define IN_ROXEN
Roxen.git/server/base_server/roxen.pike:5587:      void create_pid_file(string where)   {   #ifndef __NT__    if(!where) return;   // where = replace(where, ({ "$pid", "$uid" }),   // ({ (string)getpid(), (string)getuid() }));       object privs = Privs("Deleting old pid file.");    r_rm(where); +  +  // NB: The following won't work if there's a wrapper process +  // for Roxen (eg started via gdb, truss or valgrind), +  // but that shouldn't matter much, since the pid lock file +  // won't be used in that case anyway. +  privs = Privs("Creating pid lock."); +  mixed err; +  if (catch { +  // Try /var/run/ first. +  hardlink(sprintf("/var/run/roxen-start.%d.pid", getppid()), +  sprintf("/var/run/roxen-server.%d.pid", getpid())); +  } && (err = catch { +  // And then /tmp/. +  hardlink(sprintf("/tmp/roxen-start.%d.pid", getppid()), +  sprintf("/tmp/roxen-server.%d.pid", getpid())); +  })) { +  report_debug("Cannot create the pid lock file %O: %s", +  sprintf("/tmp/roxen-server.%d.pid", getpid()), +  describe_error(err)); +  }    privs = 0; -  if(mixed err = catch { +  if(err = catch {    Stdio.write_file(where, sprintf("%d\n%d\n", getpid(), getppid()));    })    report_debug("Cannot create the pid file %O: %s",    where, describe_error (err));   #endif   }      Pipe.pipe shuffle(Stdio.File from, Stdio.File to,    Stdio.File|void to2,    function(:void)|void callback)