Class: HawatelPS::Windows::ProcControl
- Inherits:
-
Object
- Object
- HawatelPS::Windows::ProcControl
- Defined in:
- lib/hawatel_ps/windows/proc_control.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#resume ⇒ String
Resume suspended process.
-
#status ⇒ String
Check current process status.
-
#suspend ⇒ String
Suspend process without loss data.
-
#terminate ⇒ Integer
Terminate process.
Instance Method Details
#resume ⇒ String
Resume suspended process
40 41 42 43 44 |
# File 'lib/hawatel_ps/windows/proc_control.rb', line 40 def resume # TODO There is no ResumeProcess API function in Windows. # This was described in article: http://www.codeproject.com/Articles/2964/Win-process-suspend-resume-tool # The resume method isn't not save end |
#status ⇒ String
Check current process status
12 13 14 15 16 17 18 19 |
# File 'lib/hawatel_ps/windows/proc_control.rb', line 12 def status Process.kill 0, @proc_attrs[:processid].to_i return "running" rescue Errno::ESRCH return "not running" rescue Errno::EPERM return 'non-privilaged operation' end |
#suspend ⇒ String
Suspend process without loss data
28 29 30 31 32 |
# File 'lib/hawatel_ps/windows/proc_control.rb', line 28 def suspend # TODO There is no SuspendProcess API function in Windows. # This was described in article: http://www.codeproject.com/Articles/2964/Win-process-suspend-resume-tool # The suspend method isn't not save end |
#terminate ⇒ Integer
Terminate process
60 61 62 63 64 65 |
# File 'lib/hawatel_ps/windows/proc_control.rb', line 60 def terminate return @proc_attrs[:wmi_object].Terminate if @proc_attrs[:wmi_object].ole_respond_to?('Terminate') rescue WIN32OLERuntimeError => ex #raise HawatelPSException, :exception => ex, :message => "Cannot terminate process by WMI method Terminate()." return 1 end |