benchmarks/vendor/forever/node_modules/daemon/src/daemon.cc
//
// File-lock to make sure that only one instance of daemon is running, also for storing pid
//   lock (filename)
//   @filename: a path to a lock-file.
// 
//   Note: if filename doesn't exist, it will be created when function is called.
//
File-lock to make sure that only one instance of daemon is running, also for storing pid
lock (filename)
@filename: a path to a lock-file.

if filename doesn't exist, it will be created when function is called.
File - lock to make sure that only one instance of daemon is running also for storing pid lock ( filename ) @filename : a path to a lock - file . if filename doesn ' t exist it will be created when function is called .
Handle<Value> LockD(const Arguments& args) {
  if (!args[0]->IsString())
    return Boolean::New(false);
  String::Utf8Value data(args[0]->ToString());
  char pid_str[PID_MAXLEN+1];
  int lfp = open(*data, O_RDWR | O_CREAT | O_TRUNC, 0640);
  if(lfp < 0) exit(1);
  if(lockf(lfp, F_TLOCK, 0) < 0) exit(0);
  int len = snprintf(pid_str, PID_MAXLEN, "%d", getpid());
  write(lfp, pid_str, len);
  return Boolean::New(true);
}
Handle < Value > LockD ( const Arguments & args ) { if ( ! args [ 0 ] -> IsString ( ) ) return Boolean :: New ( false ) ; String :: Utf8Value data ( args [ 0 ] -> ToString ( ) ) ; char pid_str [ PID_MAXLEN + 1 ] ; int lfp = open ( * data , O_RDWR | O_CREAT | O_TRUNC , 0640 ) ; if ( lfp < 0 ) exit ( 1 ) ; if ( lockf ( lfp , F_TLOCK , 0 ) < 0 ) exit ( 0 ) ; int len = snprintf ( pid_str , PID_MAXLEN , " " , getpid ( ) ) ; write ( lfp , pid_str , len ) ; return Boolean :: New ( true ) ; }
File-lock to make sure that only one instance of daemon is running, also for storing pid
lock (filename)
@filename: a path to a lock-file.
File - lock to make sure that only one instance of daemon is running also for storing pid lock ( filename ) @filename : a path to a lock - file .