module Spring::SID

Public Class Methods

fiddle_func() click to toggle source
# File lib/spring/sid.rb, line 15
def self.fiddle_func
  @fiddle_func ||= Fiddle::Function.new(
    DL::Handle::DEFAULT['getsid'],
    [Fiddle::TYPE_INT],
    Fiddle::TYPE_INT
  )
end
pgid() click to toggle source
# File lib/spring/sid.rb, line 38
def self.pgid
  Process.getpgid(sid)
end
sid() click to toggle source
# File lib/spring/sid.rb, line 23
def self.sid
  @sid ||= begin
    if Process.respond_to?(:getsid)
      # Ruby 2
      Process.getsid
    elsif defined?(Fiddle)
      # Ruby 1.9.3 compiled with libffi support
      fiddle_func.call(0)
    else
      # last resort: shell out
      %xps -p #{Process.pid} -o sess=`.to_i
    end
  end
end