Module: Sudo::System

Defined in:
lib/sudo/system.rb

Defined Under Namespace

Classes: FileStillExists, ProcessStillExists

Class Method Summary collapse

Class Method Details

.checkObject

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

Raises:

  • (SudoFailed)


30
31
32
# File 'lib/sudo/system.rb', line 30

def check
  raise SudoFailed unless system "sudo ruby -e ''"
end

.kill(pid) ⇒ Object



12
13
14
15
16
17
18
19
# 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


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

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