class Process
Defined in:
kernel.crprocess.cr
Class Method Summary
-
.after_fork_child_callbacks
hooks defined here due to load order problems
-
.exec(command : String, args = nil, env : Env = nil, clear_env : Bool = false, shell : Bool = false, input : Bool | IO::FileDescriptor = true, output : Bool | IO::FileDescriptor = true, error : Bool | IO::FileDescriptor = true, chdir : String | Nil = nil)
Replaces the current process with a new one.
-
.exists?(pid : Int)
Returns true if the process identified by pid is valid for a currently registered process, false otherwise.
-
.exit(status = 0)
Terminate the current process immediately.
-
.fork(&block)
Runs the given block inside a new process and returns a
Process
representing the new child process. -
.fork : self | Nil
Duplicates the current process.
-
.kill(signal : Signal, *pids : Int)
Sends a signal to the processes identified by the given pids.
- .new(pid)
-
.new(command : String, args = nil, env : Env = nil, clear_env : Bool = false, shell : Bool = false, input : Stdio = false, output : Stdio = false, error : Stdio = false, chdir : String | Nil = nil)
Creates a process, executes it, but doesn't wait for it to complete.
-
.pgid(pid : Int32) : LibC::PidT
Returns the process group identifier of the process identified by pid.
-
.pgid : LibC::PidT
Returns the process group identifier of the current process.
-
.pid : LibC::PidT
Returns the process identifier of the current process.
-
.ppid : LibC::PidT
Returns the process identifier of the parent process of the current process.
-
.run(command : String, args = nil, env : Env = nil, clear_env : Bool = false, shell : Bool = false, input : Stdio = false, output : Stdio = false, error : Stdio = false, chdir : String | Nil = nil) : Process::Status
Executes a process and waits for it to complete.
-
.run(command : String, args = nil, env : Env = nil, clear_env : Bool = false, shell : Bool = false, input : Stdio = nil, output : Stdio = nil, error : Stdio = nil, chdir : String | Nil = nil, &block)
Executes a process, yields the block, and then waits for it to finish.
-
.times : Tms
Returns a
Tms
for the current process.
Instance Method Summary
-
#close
Closes any pipes to the child process.
-
#error
A pipe to this process's error.
-
#error? : IO::FileDescriptor | Nil
A pipe to this process's error.
-
#exists?
Whether the process is still registered in the system.
-
#input
A pipe to this process's input.
-
#input? : IO::FileDescriptor | Nil
A pipe to this process's input.
-
#kill(sig = Signal::TERM)
See
Process.kill
-
#output
A pipe to this process's output.
-
#output? : IO::FileDescriptor | Nil
A pipe to this process's output.
- #pid : Int32
-
#terminated?
Whether this process is already terminated.
-
#wait : Process::Status
Waits for this process to complete and closes any pipes.
Instance methods inherited from class Reference
==(other)==(other : self) ==, dup dup, hash hash, inspect(io : IO) : Nil inspect, object_id : UInt64 object_id, same?(other : Reference)
same?(other : Nil) same?, to_s(io : IO) : Nil to_s
Instance methods inherited from class Object
!=(other)
!=,
!~(other)
!~,
==(other)
==,
===(other)===(other : YAML::Any)
===(other : JSON::Any) ===, =~(other) =~, class class, crystal_type_id crystal_type_id, dup dup, hash hash, inspect(io : IO)
inspect inspect, itself itself, not_nil! not_nil!, tap(&block) tap, to_json to_json, to_pretty_json(indent : String = " ")
to_pretty_json(io : IO, indent : String = " ") to_pretty_json, to_s
to_s(io : IO) to_s, to_yaml
to_yaml(io : IO) to_yaml, try(&block) try
Class methods inherited from class Object
==(other : Class)
==,
===(other)
===,
cast(other) : self
cast,
clone
clone,
dup
dup,
from_json(string_or_io) : selffrom_json(string_or_io, root : String) : self from_json, from_yaml(string : String) : self from_yaml, hash hash, inspect(io) inspect, name : String name, nilable? nilable?, to_s(io) to_s, |(other : U.class) forall U |
Class Method Detail
Replaces the current process with a new one.
The possible values for input, output and error are:
false
: no IO (/dev/null
)true
: inherit from parentIO
: use the given IO
Returns true if the process identified by pid is valid for a currently registered process, false otherwise. Note that this returns true for a process in the zombie or similar state.
Terminate the current process immediately. All open files, pipes and sockets
are flushed and closed, all child processes are inherited by PID 1. This does
not run any handlers registered with at_exit
, use ::exit
for that.
status is the exit status of the current process.
Runs the given block inside a new process and
returns a Process
representing the new child process.
Duplicates the current process.
Returns a Process
representing the new child process in the current process
and nil inside the new child process.
Sends a signal to the processes identified by the given pids.
Creates a process, executes it, but doesn't wait for it to complete.
To wait for it to finish, invoke #wait
.
By default the process is configured without input, output or error.
Returns the process group identifier of the process identified by pid.
Returns the process identifier of the parent process of the current process.
Executes a process and waits for it to complete.
By default the process is configured without input, output or error.
Executes a process, yields the block, and then waits for it to finish.
By default the process is configured to use pipes for input, output and error. These will be closed automatically at the end of the block.
Returns the block's value.
Returns a Tms
for the current process. For the children times, only those
of terminated children are returned.
Instance Method Detail
A pipe to this process's error. Raises if a pipe wasn't asked when creating the process.
A pipe to this process's error. Raises if a pipe wasn't asked when creating the process.
Whether the process is still registered in the system. Note that this returns true for processes in the zombie or similar state.
A pipe to this process's input. Raises if a pipe wasn't asked when creating the process.
A pipe to this process's input. Raises if a pipe wasn't asked when creating the process.
A pipe to this process's output. Raises if a pipe wasn't asked when creating the process.
A pipe to this process's output. Raises if a pipe wasn't asked when creating the process.