Method: MemoryIO::Process#initialize
- Defined in:
- lib/memory_io/process.rb
#initialize(pid) ⇒ Process
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
TODO:
Support MacOS
TODO:
Support Windows
Note:
This class only supports procfs-based system. i.e. /proc is mounted and readable.
Create process object from pid.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/memory_io/process.rb', line 22 def initialize(pid) @pid = pid @mem = "/proc/#{pid}/mem" # check permission of '/proc/pid/mem' @perm = MemoryIO::Util.(@mem) # TODO: raise custom exception raise Errno::ENOENT, @mem if perm.nil? # FIXME: use logger warn(<<-EOS.strip) unless perm.readable? || perm.writable? You have no permission to read/write this process. Check the setting of /proc/sys/kernel/yama/ptrace_scope, or try again as the root user. To enable attach another process, do: $ echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope EOS end |