Module: Sudo::System
- Defined in:
- lib/sudo/system.rb
Constant Summary collapse
- ProcessStillExists =
Class.new(RuntimeError)
- FileStillExists =
Class.new(RuntimeError)
Class Method Summary collapse
-
.check ⇒ Object
just to check if we can sudo; and we’ll receive a sudo token.
- .kill(pid) ⇒ Object
- .unlink(file) ⇒ Object
Class Method Details
.check ⇒ Object
just to check if we can sudo; and we’ll receive a sudo token
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 |
.unlink(file) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/sudo/system.rb', line 20 def unlink(file) if file and File.exists? file system("sudo rm -f #{file}") or raise(FileStillExists, "Couldn't delete #{file}") end end |