Module: Kernel

Defined in:
lib/fuxed_lock.rb

Class Method Summary collapse

Class Method Details

.`(cmd) ⇒ Object



63
64
65
66
67
68
# File 'lib/fuxed_lock.rb', line 63

def self.`(cmd)
  pipe = self.popen(cmd)
  res = pipe.read
  pipe.close
  return res
end

.popen(cmd, mode = ?r) ⇒ Object



55
56
57
58
59
60
61
# File 'lib/fuxed_lock.rb', line 55

def self.popen(cmd, mode = ?r)
  return unless [?r, ?w].include? mode
  fp = LibC.popen(cmd, mode)
  return if fp.null?
  fp = LibC::FILE.new(fp)
  IO.new(fp[:_fileno], mode)
end

.system(cmd) ⇒ Object



70
71
72
73
74
75
76
77
78
79
# File 'lib/fuxed_lock.rb', line 70

def self.system(cmd)
  io = self.popen(cmd)
  io.sync = true

  io.each_line {|line|
    $stdout.puts line
  }

  io.close
end