/usr/lib/ruby/vendor_ruby/specinfra/command/windows/base/process.rb is in ruby-specinfra 2.35.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | class Specinfra::Command::Windows::Base::Process < Specinfra::Command::Windows::Base
class << self
def check_process(process)
Backend::PowerShell::Command.new do
exec "(Get-Process '#{process}') -ne $null"
end
end
def get(process, opts)
column = opts[:format].chomp '='
case column
when 'pid'
# map 'pid' to its windows equivalent
get_process_property(process, 'processid')
when 'user'
%Q!gwmi win32_process -filter "name = '#{process}'" | select -first 1 | %{$_.getowner().user}!
when 'group'
# no concept of process group on Windows
raise NotImplementedError.new('Unable to get process group on Windows')
else
get_process_property(process, column)
end
end
private
def get_process_property(process, property)
%Q!Get-WmiObject Win32_Process -Filter "name = '#{process}'" | select -First 1 #{property} -ExpandProperty #{property}!
end
end
end
|