def write_pidfile(filename)
      pf =
        begin
          tmp = "#{filename}.#{rand}.#{$$}"
          File.open(tmp, File::RDWR | File::CREAT | File::EXCL, 0644)
        rescue Errno::EEXIST
          retry
        end
      pf.syswrite("#{$$}\n")
      File.rename(pf.path, filename)
      pf.close
    end
def write_pidfile(filename)
      pf =
        begin
          tmp = "#{filename}.#{rand}.#{$$}"
          File.open(tmp, File::RDWR | File::CREAT | File::EXCL, 0644)
        rescue Errno::EEXIST
          retry
        end
      pf.syswrite("#{$$}\n")
      File.rename(pf.path, filename)
      pf.close
    end
Private.