Module: Sudo::System

Defined in:
lib/sudo/system.rb

Constant Summary collapse

ProcessStillExists =
Class.new(RuntimeError)
FileStillExists =
Class.new(RuntimeError)

Class Method Summary collapse

Class Method Details

.checkObject

just to check if we can sudo; and we’ll receive a sudo token

Raises:

  • (SudoFailed)


28
29
30
# File 'lib/sudo/system.rb', line 28

def check
  raise SudoFailed unless system "#{SUDO_CMD} -E #{RUBY_CMD} -e ''"
end

.kill(pid) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/sudo/system.rb', line 12

def kill(pid)
  if pid and Process.exists? pid
    system "sudo kill     #{pid}" or
    system "sudo kill -9  #{pid}" or
    raise ProcessStillExists, "Couldn't kill sudo process (PID=#{pid})"
  end
end


20
21
22
23
24
25
# File 'lib/sudo/system.rb', line 20

def unlink(file)
  if file and File.exist? file
    system("sudo rm -f #{file}") or
    raise(FileStillExists, "Couldn't delete #{file}")
  end
end