# File lib/rq-2.3.1/relayer.rb, line 125
      def gen_pidfile name = nil
#--{{{
        name ||= gen_relayer_name(@options['name'] || @qpath)
        @pidfile = 
          begin
            open name, File::CREAT | File::EXCL | File::RDWR
          rescue
            open name, File::RDWR
          end
        unless @pidfile and @pidfile.posixlock(File::LOCK_EX | File::LOCK_NB)
          pid = IO::read(name) rescue nil
          pid ||= 'unknown'
          if @options['quiet']
            exit EXIT_FAILURE
          else
            raise "process <#{ pid }> is already relaying from this queue"
          end
        else
          @pidfile.rewind
          @pidfile.sync = true
          @pidfile.print Process::pid
          @pidfile.truncate @pidfile.pos
          at_exit{ FileUtils::rm_f name rescue nil }
        end
#--}}}
      end