Module: Spring::SID

Defined in:
lib/spring/sid.rb

Class Method Summary collapse

Class Method Details

.fiddle_funcObject



15
16
17
18
19
20
21
# 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

.pgidObject



38
39
40
# File 'lib/spring/sid.rb', line 38

def self.pgid
  Process.getpgid(sid)
end

.sidObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/spring/sid.rb', line 23

def self.sid
  @sid ||= begin
    if Process.respond_to?(:getsid)
      # Ruby 2
      Process.getsid
    elsif defined?(Fiddle) and defined?(DL)
      # Ruby 1.9.3 compiled with libffi support
      fiddle_func.call(0)
    else
      # last resort: shell out
      `ps -p #{Process.pid} -o sess=`.to_i
    end
  end
end