class Async::Container::Forked::Child::Instance
Represents a running child process from the point of view of the child process.
def self.for(process)
Wrap an instance around the {Process} instance from within the forked child.
def self.for(process) instance = self.new(process.out) # The child process won't be reading from the channel: process.close_read instance.name = process.name return instance end
def as_json(...)
Generate a hash representation of the process.
def as_json(...) { process_id: ::Process.pid, name: @name, } end
def exec(*arguments, ready: true, **options)
@parameter ready [Boolean] If true, informs the parent process that the child is ready. Otherwise, the child process will need to use a notification protocol to inform the parent process that it is ready.
@parameter arguments [Array] The arguments to pass to the new process.
This method replaces the child process with the new executable, thus this method never returns.
Replace the current child process with a different one. Forwards arguments and options to {::Process.exec}.
def exec(*arguments, ready: true, **options) if ready self.ready!(status: "(exec)") else self.before_spawn(arguments, options) end ::Process.exec(*arguments, **options) end
def initialize(io)
Initialize the child process instance.
def initialize(io) super @name = nil end
def name
def name @name end
def name= value
Set the process title to the specified value.
def name= value @name = value # This sets the process title to an empty string if the name is nil: ::Process.setproctitle(@name.to_s) end
def to_json(...)
Generate a JSON representation of the process.
def to_json(...) as_json.to_json(...) end