Class: OsCtl::Lib::PidFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/libosctl/pid_finder.rb

Overview

Locate containers by process IDs from the host

Defined Under Namespace

Classes: Result

Instance Method Summary collapse

Instance Method Details

#find(pid) ⇒ Result?

Parameters:

  • pid (Integer)

    process ID from the host

Returns:



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/libosctl/pid_finder.rb', line 8

def find(pid)
  os_proc = OsProcess.new(pid)
  ctid = os_proc.ct_id

  if ctid.nil?
    Result.new(nil, :host, os_proc)
  else
    pool, id = ctid
    Result.new(pool, id, os_proc)
  end

rescue Exceptions::OsProcessNotFound
  nil
end