Basically a wrapper for Open3.popen3
that:
Creates a child process, by calling Open3.popen3
with the given arguments (except for certain entries in hash options
; see below).
Returns as strings stdout_s
and stderr_s
the standard output and standard error of the child process.
Returns as status
a Process::Status
object that represents the exit status of the child process.
Returns the array [stdout_s, stderr_s, status]
:
stdout_s, stderr_s, status = Open3.capture3('echo "Foo"') # => ["Foo\n", "", #<Process::Status: pid 2281954 exit 0>]
Like Process.spawn
, this method has potential security vulnerabilities if called with untrusted input; see Command Injection.
Unlike Process.spawn
, this method waits for the child process to exit before returning, so the caller need not do so.
If the first argument is a hash, it becomes leading argument env
in the call to Open3.popen3
; see Execution Environment.
If the last argument is a hash, it becomes trailing argument options
in the call to Open3.popen3
; see Execution Options.
The hash options
is given; two options have local effect in method Open3.capture3
:
If entry options[:stdin_data]
exists, the entry is removed and its string value is sent to the command’s standard input:
Open3.capture3('tee', stdin_data: 'Foo') # => ["Foo", "", #<Process::Status: pid 2319575 exit 0>]
If entry options[:binmode]
exists, the entry is removed and the internal streams are set to binary mode.
The single required argument is one of the following:
command_line
if it is a string, and if it begins with a shell reserved word or special built-in, or if it contains one or more metacharacters.
exe_path
otherwise.
Argument command_line
String argument command_line
is a command line to be passed to a shell; it must begin with a shell reserved word, begin with a special built-in, or contain meta characters:
Open3.capture3('if true; then echo "Foo"; fi') # Shell reserved word. # => ["Foo\n", "", #<Process::Status: pid 2282025 exit 0>] Open3.capture3('echo') # Built-in. # => ["\n", "", #<Process::Status: pid 2282092 exit 0>] Open3.capture3('date > date.tmp') # Contains meta character. # => ["", "", #<Process::Status: pid 2282110 exit 0>]
The command line may also contain arguments and options for the command:
Open3.capture3('echo "Foo"') # => ["Foo\n", "", #<Process::Status: pid 2282092 exit 0>]
Argument exe_path
Argument exe_path
is one of the following:
The string path to an executable to be called.
A 2-element array containing the path to an executable and the string to be used as the name of the executing process.
Example:
Open3.capture3('/usr/bin/date') # => ["Thu Sep 28 05:03:51 PM CDT 2023\n", "", #<Process::Status: pid 2282300 exit 0>]
Ruby invokes the executable directly, with no shell and no shell expansion:
Open3.capture3('doesnt_exist') # Raises Errno::ENOENT
If one or more args
is given, each is an argument or option to be passed to the executable:
Open3.capture3('echo', 'C #') # => ["C #\n", "", #<Process::Status: pid 2282368 exit 0>] Open3.capture3('echo', 'hello', 'world') # => ["hello world\n", "", #<Process::Status: pid 2282372 exit 0>]
Basically a wrapper for Open3.popen3
that:
Creates a child process, by calling Open3.popen3
with the given arguments (except for certain entries in hash options
; see below).
Returns as strings stdout_s
and stderr_s
the standard output and standard error of the child process.
Returns as status
a Process::Status
object that represents the exit status of the child process.
Returns the array [stdout_s, stderr_s, status]
:
stdout_s, stderr_s, status = Open3.capture3('echo "Foo"') # => ["Foo\n", "", #<Process::Status: pid 2281954 exit 0>]
Like Process.spawn
, this method has potential security vulnerabilities if called with untrusted input; see Command Injection.
Unlike Process.spawn
, this method waits for the child process to exit before returning, so the caller need not do so.
If the first argument is a hash, it becomes leading argument env
in the call to Open3.popen3
; see Execution Environment.
If the last argument is a hash, it becomes trailing argument options
in the call to Open3.popen3
; see Execution Options.
The hash options
is given; two options have local effect in method Open3.capture3
:
If entry options[:stdin_data]
exists, the entry is removed and its string value is sent to the command’s standard input:
Open3.capture3('tee', stdin_data: 'Foo') # => ["Foo", "", #<Process::Status: pid 2319575 exit 0>]
If entry options[:binmode]
exists, the entry is removed and the internal streams are set to binary mode.
The single required argument is one of the following:
command_line
if it is a string, and if it begins with a shell reserved word or special built-in, or if it contains one or more metacharacters.
exe_path
otherwise.
Argument command_line
String argument command_line
is a command line to be passed to a shell; it must begin with a shell reserved word, begin with a special built-in, or contain meta characters:
Open3.capture3('if true; then echo "Foo"; fi') # Shell reserved word. # => ["Foo\n", "", #<Process::Status: pid 2282025 exit 0>] Open3.capture3('echo') # Built-in. # => ["\n", "", #<Process::Status: pid 2282092 exit 0>] Open3.capture3('date > date.tmp') # Contains meta character. # => ["", "", #<Process::Status: pid 2282110 exit 0>]
The command line may also contain arguments and options for the command:
Open3.capture3('echo "Foo"') # => ["Foo\n", "", #<Process::Status: pid 2282092 exit 0>]
Argument exe_path
Argument exe_path
is one of the following:
The string path to an executable to be called.
A 2-element array containing the path to an executable and the string to be used as the name of the executing process.
Example:
Open3.capture3('/usr/bin/date') # => ["Thu Sep 28 05:03:51 PM CDT 2023\n", "", #<Process::Status: pid 2282300 exit 0>]
Ruby invokes the executable directly, with no shell and no shell expansion:
Open3.capture3('doesnt_exist') # Raises Errno::ENOENT
If one or more args
is given, each is an argument or option to be passed to the executable:
Open3.capture3('echo', 'C #') # => ["C #\n", "", #<Process::Status: pid 2282368 exit 0>] Open3.capture3('echo', 'hello', 'world') # => ["hello world\n", "", #<Process::Status: pid 2282372 exit 0>]
Basically a wrapper for Open3.popen3
that:
Creates a child process, by calling Open3.popen3
with the given arguments (except for certain entries in hash options
; see below).
Returns as string stdout_s
the standard output of the child process.
Returns as status
a Process::Status
object that represents the exit status of the child process.
Returns the array [stdout_s, status]
:
stdout_s, status = Open3.capture2('echo "Foo"') # => ["Foo\n", #<Process::Status: pid 2326047 exit 0>]
Like Process.spawn
, this method has potential security vulnerabilities if called with untrusted input; see Command Injection.
Unlike Process.spawn
, this method waits for the child process to exit before returning, so the caller need not do so.
If the first argument is a hash, it becomes leading argument env
in the call to Open3.popen3
; see Execution Environment.
If the last argument is a hash, it becomes trailing argument options
in the call to Open3.popen3
; see Execution Options.
The hash options
is given; two options have local effect in method Open3.capture2
:
If entry options[:stdin_data]
exists, the entry is removed and its string value is sent to the command’s standard input:
Open3.capture2('tee', stdin_data: 'Foo') # => ["Foo", #<Process::Status: pid 2326087 exit 0>]
If entry options[:binmode]
exists, the entry is removed and the internal streams are set to binary mode.
The single required argument is one of the following:
command_line
if it is a string, and if it begins with a shell reserved word or special built-in, or if it contains one or more metacharacters.
exe_path
otherwise.
Argument command_line
String argument command_line
is a command line to be passed to a shell; it must begin with a shell reserved word, begin with a special built-in, or contain meta characters:
Open3.capture2('if true; then echo "Foo"; fi') # Shell reserved word. # => ["Foo\n", #<Process::Status: pid 2326131 exit 0>] Open3.capture2('echo') # Built-in. # => ["\n", #<Process::Status: pid 2326139 exit 0>] Open3.capture2('date > date.tmp') # Contains meta character. # => ["", #<Process::Status: pid 2326174 exit 0>]
The command line may also contain arguments and options for the command:
Open3.capture2('echo "Foo"') # => ["Foo\n", #<Process::Status: pid 2326183 exit 0>]
Argument exe_path
Argument exe_path
is one of the following:
The string path to an executable to be called.
A 2-element array containing the path to an executable and the string to be used as the name of the executing process.
Example:
Open3.capture2('/usr/bin/date') # => ["Fri Sep 29 01:00:39 PM CDT 2023\n", #<Process::Status: pid 2326222 exit 0>]
Ruby invokes the executable directly, with no shell and no shell expansion:
Open3.capture2('doesnt_exist') # Raises Errno::ENOENT
If one or more args
is given, each is an argument or option to be passed to the executable:
Open3.capture2('echo', 'C #') # => ["C #\n", #<Process::Status: pid 2326267 exit 0>] Open3.capture2('echo', 'hello', 'world') # => ["hello world\n", #<Process::Status: pid 2326299 exit 0>]
Basically a wrapper for Open3.popen3
that:
Creates a child process, by calling Open3.popen3
with the given arguments (except for certain entries in hash options
; see below).
Returns as string stdout_s
the standard output of the child process.
Returns as status
a Process::Status
object that represents the exit status of the child process.
Returns the array [stdout_s, status]
:
stdout_s, status = Open3.capture2('echo "Foo"') # => ["Foo\n", #<Process::Status: pid 2326047 exit 0>]
Like Process.spawn
, this method has potential security vulnerabilities if called with untrusted input; see Command Injection.
Unlike Process.spawn
, this method waits for the child process to exit before returning, so the caller need not do so.
If the first argument is a hash, it becomes leading argument env
in the call to Open3.popen3
; see Execution Environment.
If the last argument is a hash, it becomes trailing argument options
in the call to Open3.popen3
; see Execution Options.
The hash options
is given; two options have local effect in method Open3.capture2
:
If entry options[:stdin_data]
exists, the entry is removed and its string value is sent to the command’s standard input:
Open3.capture2('tee', stdin_data: 'Foo') # => ["Foo", #<Process::Status: pid 2326087 exit 0>]
If entry options[:binmode]
exists, the entry is removed and the internal streams are set to binary mode.
The single required argument is one of the following:
command_line
if it is a string, and if it begins with a shell reserved word or special built-in, or if it contains one or more metacharacters.
exe_path
otherwise.
Argument command_line
String argument command_line
is a command line to be passed to a shell; it must begin with a shell reserved word, begin with a special built-in, or contain meta characters:
Open3.capture2('if true; then echo "Foo"; fi') # Shell reserved word. # => ["Foo\n", #<Process::Status: pid 2326131 exit 0>] Open3.capture2('echo') # Built-in. # => ["\n", #<Process::Status: pid 2326139 exit 0>] Open3.capture2('date > date.tmp') # Contains meta character. # => ["", #<Process::Status: pid 2326174 exit 0>]
The command line may also contain arguments and options for the command:
Open3.capture2('echo "Foo"') # => ["Foo\n", #<Process::Status: pid 2326183 exit 0>]
Argument exe_path
Argument exe_path
is one of the following:
The string path to an executable to be called.
A 2-element array containing the path to an executable and the string to be used as the name of the executing process.
Example:
Open3.capture2('/usr/bin/date') # => ["Fri Sep 29 01:00:39 PM CDT 2023\n", #<Process::Status: pid 2326222 exit 0>]
Ruby invokes the executable directly, with no shell and no shell expansion:
Open3.capture2('doesnt_exist') # Raises Errno::ENOENT
If one or more args
is given, each is an argument or option to be passed to the executable:
Open3.capture2('echo', 'C #') # => ["C #\n", #<Process::Status: pid 2326267 exit 0>] Open3.capture2('echo', 'hello', 'world') # => ["hello world\n", #<Process::Status: pid 2326299 exit 0>]
Basically a wrapper for Open3.popen3
that:
Creates a child process, by calling Open3.popen3
with the given arguments (except for certain entries in hash options
; see below).
Returns as string stdout_and_stderr_s
the merged standard output and standard error of the child process.
Returns as status
a Process::Status
object that represents the exit status of the child process.
Returns the array [stdout_and_stderr_s, status]
:
stdout_and_stderr_s, status = Open3.capture2e('echo "Foo"') # => ["Foo\n", #<Process::Status: pid 2371692 exit 0>]
Like Process.spawn
, this method has potential security vulnerabilities if called with untrusted input; see Command Injection.
Unlike Process.spawn
, this method waits for the child process to exit before returning, so the caller need not do so.
If the first argument is a hash, it becomes leading argument env
in the call to Open3.popen3
; see Execution Environment.
If the last argument is a hash, it becomes trailing argument options
in the call to Open3.popen3
; see Execution Options.
The hash options
is given; two options have local effect in method Open3.capture2e
:
If entry options[:stdin_data]
exists, the entry is removed and its string value is sent to the command’s standard input:
Open3.capture2e('tee', stdin_data: 'Foo') # => ["Foo", #<Process::Status: pid 2371732 exit 0>]
If entry options[:binmode]
exists, the entry is removed and the internal streams are set to binary mode.
The single required argument is one of the following:
command_line
if it is a string, and if it begins with a shell reserved word or special built-in, or if it contains one or more metacharacters.
exe_path
otherwise.
Argument command_line
String argument command_line
is a command line to be passed to a shell; it must begin with a shell reserved word, begin with a special built-in, or contain meta characters:
Open3.capture2e('if true; then echo "Foo"; fi') # Shell reserved word. # => ["Foo\n", #<Process::Status: pid 2371740 exit 0>] Open3.capture2e('echo') # Built-in. # => ["\n", #<Process::Status: pid 2371774 exit 0>] Open3.capture2e('date > date.tmp') # Contains meta character. # => ["", #<Process::Status: pid 2371812 exit 0>]
The command line may also contain arguments and options for the command:
Open3.capture2e('echo "Foo"') # => ["Foo\n", #<Process::Status: pid 2326183 exit 0>]
Argument exe_path
Argument exe_path
is one of the following:
The string path to an executable to be called.
A 2-element array containing the path to an executable and the string to be used as the name of the executing process.
Example:
Open3.capture2e('/usr/bin/date') # => ["Sat Sep 30 09:01:46 AM CDT 2023\n", #<Process::Status: pid 2371820 exit 0>]
Ruby invokes the executable directly, with no shell and no shell expansion:
Open3.capture2e('doesnt_exist') # Raises Errno::ENOENT
If one or more args
is given, each is an argument or option to be passed to the executable:
Open3.capture2e('echo', 'C #') # => ["C #\n", #<Process::Status: pid 2371856 exit 0>] Open3.capture2e('echo', 'hello', 'world') # => ["hello world\n", #<Process::Status: pid 2371894 exit 0>]
Basically a wrapper for Open3.popen3
that:
Creates a child process, by calling Open3.popen3
with the given arguments (except for certain entries in hash options
; see below).
Returns as string stdout_and_stderr_s
the merged standard output and standard error of the child process.
Returns as status
a Process::Status
object that represents the exit status of the child process.
Returns the array [stdout_and_stderr_s, status]
:
stdout_and_stderr_s, status = Open3.capture2e('echo "Foo"') # => ["Foo\n", #<Process::Status: pid 2371692 exit 0>]
Like Process.spawn
, this method has potential security vulnerabilities if called with untrusted input; see Command Injection.
Unlike Process.spawn
, this method waits for the child process to exit before returning, so the caller need not do so.
If the first argument is a hash, it becomes leading argument env
in the call to Open3.popen3
; see Execution Environment.
If the last argument is a hash, it becomes trailing argument options
in the call to Open3.popen3
; see Execution Options.
The hash options
is given; two options have local effect in method Open3.capture2e
:
If entry options[:stdin_data]
exists, the entry is removed and its string value is sent to the command’s standard input:
Open3.capture2e('tee', stdin_data: 'Foo') # => ["Foo", #<Process::Status: pid 2371732 exit 0>]
If entry options[:binmode]
exists, the entry is removed and the internal streams are set to binary mode.
The single required argument is one of the following:
command_line
if it is a string, and if it begins with a shell reserved word or special built-in, or if it contains one or more metacharacters.
exe_path
otherwise.
Argument command_line
String argument command_line
is a command line to be passed to a shell; it must begin with a shell reserved word, begin with a special built-in, or contain meta characters:
Open3.capture2e('if true; then echo "Foo"; fi') # Shell reserved word. # => ["Foo\n", #<Process::Status: pid 2371740 exit 0>] Open3.capture2e('echo') # Built-in. # => ["\n", #<Process::Status: pid 2371774 exit 0>] Open3.capture2e('date > date.tmp') # Contains meta character. # => ["", #<Process::Status: pid 2371812 exit 0>]
The command line may also contain arguments and options for the command:
Open3.capture2e('echo "Foo"') # => ["Foo\n", #<Process::Status: pid 2326183 exit 0>]
Argument exe_path
Argument exe_path
is one of the following:
The string path to an executable to be called.
A 2-element array containing the path to an executable and the string to be used as the name of the executing process.
Example:
Open3.capture2e('/usr/bin/date') # => ["Sat Sep 30 09:01:46 AM CDT 2023\n", #<Process::Status: pid 2371820 exit 0>]
Ruby invokes the executable directly, with no shell and no shell expansion:
Open3.capture2e('doesnt_exist') # Raises Errno::ENOENT
If one or more args
is given, each is an argument or option to be passed to the executable:
Open3.capture2e('echo', 'C #') # => ["C #\n", #<Process::Status: pid 2371856 exit 0>] Open3.capture2e('echo', 'hello', 'world') # => ["hello world\n", #<Process::Status: pid 2371894 exit 0>]
Compatibility methods for Ruby 3.2, we can remove this after dropping to support Ruby 3.2
Perform an operation in a block, raising an error if it takes longer than sec
seconds to complete.
sec
Number of seconds to wait for the block to terminate. Any non-negative number or nil may be used, including Floats to specify fractional seconds. A value of 0 or nil
will execute the block without any timeout. Any negative number will raise an ArgumentError
.
klass
Exception
Class
to raise if the block fails to terminate in sec
seconds. Omitting will use the default, Timeout::Error
message
Error
message to raise with Exception
Class
. Omitting will use the default, “execution expired”
Returns the result of the block if the block completed before sec
seconds, otherwise throws an exception, based on the value of klass
.
The exception thrown to terminate the given block cannot be rescued inside the block unless klass
is given explicitly. However, the block can use ensure to prevent the handling of the exception. For that reason, this method cannot be relied on to enforce timeouts for untrusted blocks.
If a scheduler is defined, it will be used to handle the timeout by invoking Scheduler#timeout_after.
Note that this is both a method of module Timeout
, so you can include Timeout
into your classes so they have a timeout
method, as well as a module method, so you can call it directly as Timeout.timeout()
.
Perform an operation in a block, raising an error if it takes longer than sec
seconds to complete.
sec
Number of seconds to wait for the block to terminate. Any non-negative number or nil may be used, including Floats to specify fractional seconds. A value of 0 or nil
will execute the block without any timeout. Any negative number will raise an ArgumentError
.
klass
Exception
Class
to raise if the block fails to terminate in sec
seconds. Omitting will use the default, Timeout::Error
message
Error
message to raise with Exception
Class
. Omitting will use the default, “execution expired”
Returns the result of the block if the block completed before sec
seconds, otherwise throws an exception, based on the value of klass
.
The exception thrown to terminate the given block cannot be rescued inside the block unless klass
is given explicitly. However, the block can use ensure to prevent the handling of the exception. For that reason, this method cannot be relied on to enforce timeouts for untrusted blocks.
If a scheduler is defined, it will be used to handle the timeout by invoking Scheduler#timeout_after.
Note that this is both a method of module Timeout
, so you can include Timeout
into your classes so they have a timeout
method, as well as a module method, so you can call it directly as Timeout.timeout()
.
Returns the value of the Gauss error function for x
.
Domain: [-INFINITY, INFINITY]
.
Range: [-1, 1]
.
Examples:
erf(-INFINITY) # => -1.0 erf(0.0) # => 0.0 erf(INFINITY) # => 1.0
Related: Math.erfc
.
Returns the value of the complementary error function for x
.
Domain: [-INFINITY, INFINITY]
.
Range: [0, 2]
.
Examples:
erfc(-INFINITY) # => 2.0 erfc(0.0) # => 1.0 erfc(INFINITY) # => 0.0
Related: Math.erf
.
Creates a new child process by doing one of the following in that process:
Passing string command_line
to the shell.
Invoking the executable at exe_path
.
This method has potential security vulnerabilities if called with untrusted input; see Command Injection.
Returns the process ID (pid) of the new process, without waiting for it to complete.
To avoid zombie processes, the parent process should call either:
Process.wait
, to collect the termination statuses of its children.
Process.detach
, to register disinterest in their status.
The new process is created using the exec system call; it may inherit some of its environment from the calling program (possibly including open file descriptors).
Argument env
, if given, is a hash that affects ENV
for the new process; see Execution Environment.
Argument options
is a hash of options for the new process; see Execution Options.
The first required argument is one of the following:
command_line
if it is a string, and if it begins with a shell reserved word or special built-in, or if it contains one or more meta characters.
exe_path
otherwise.
Argument command_line
String argument command_line
is a command line to be passed to a shell; it must begin with a shell reserved word, begin with a special built-in, or contain meta characters:
spawn('if true; then echo "Foo"; fi') # => 798847 # Shell reserved word. Process.wait # => 798847 spawn('exit') # => 798848 # Built-in. Process.wait # => 798848 spawn('date > /tmp/date.tmp') # => 798879 # Contains meta character. Process.wait # => 798849 spawn('date > /nop/date.tmp') # => 798882 # Issues error message. Process.wait # => 798882
The command line may also contain arguments and options for the command:
spawn('echo "Foo"') # => 799031 Process.wait # => 799031
Output:
Foo
See Execution Shell for details about the shell.
Raises an exception if the new process could not execute.
Argument exe_path
Argument exe_path
is one of the following:
The string path to an executable to be called.
A 2-element array containing the path to an executable to be called, and the string to be used as the name of the executing process.
spawn('/usr/bin/date') # Path to date on Unix-style system. Process.wait
Output:
Mon Aug 28 11:43:10 AM CDT 2023
Ruby invokes the executable directly. This form does not use the shell; see Arguments args for caveats.
If one or more args
is given, each is an argument or option to be passed to the executable:
spawn('echo', 'C*') # => 799392 Process.wait # => 799392 spawn('echo', 'hello', 'world') # => 799393 Process.wait # => 799393
Output:
C* hello world
Raises an exception if the new process could not execute.
Sets the process group ID for the process given by process ID pid
to pgid
.
Not available on all platforms.
Establishes the current process as a new session and process group leader, with no controlling tty; returns the session ID:
Process.setsid # => 27422
Not available on all platforms.
Returns the scheduling priority for specified process, process group, or user.
Argument kind
is one of:
Process::PRIO_PROCESS
: return priority for process.
Process::PRIO_PGRP
: return priority for process group.
Process::PRIO_USER
: return priority for user.
Argument id
is the ID for the process, process group, or user; zero specified the current ID for kind
.
Examples:
Process.getpriority(Process::PRIO_USER, 0) # => 19 Process.getpriority(Process::PRIO_PROCESS, 0) # => 19
Not available on all platforms.
Notify the Ruby virtual machine that the boot sequence is finished, and that now is a good time to optimize the application. This is useful for long running applications.
This method is expected to be called at the end of the application boot. If the application is deployed using a pre-forking model, Process.warmup
should be called in the original process before the first fork.
The actual optimizations performed are entirely implementation specific and may change in the future without notice.
On CRuby, Process.warmup
:
Performs a major GC
.
Compacts the heap.
Promotes all surviving objects to the old generation.
Precomputes the coderange of all strings.
Frees all empty heap pages and increments the allocatable pages counter by the number of pages freed.
Invoke malloc_trim
if available to free empty malloc pages.
Sets limits for the current process for the given resource
to cur_limit
(soft limit) and max_limit
(hard limit); returns nil
.
Argument resource
specifies the resource whose limits are to be set; the argument may be given as a symbol, as a string, or as a constant beginning with Process::RLIMIT_
(e.g., :CORE
, 'CORE'
, or Process::RLIMIT_CORE
.
The resources available and supported are system-dependent, and may include (here expressed as symbols):
:AS
: Total available memory (bytes) (SUSv3, NetBSD, FreeBSD, OpenBSD except 4.4BSD-Lite).
:CORE
: Core size (bytes) (SUSv3).
:CPU
: CPU time (seconds) (SUSv3).
:DATA
: Data
segment (bytes) (SUSv3).
:FSIZE
: File
size (bytes) (SUSv3).
:MEMLOCK
: Total size for mlock(2) (bytes) (4.4BSD, GNU/Linux).
:MSGQUEUE
: Allocation for POSIX message queues (bytes) (GNU/Linux).
:NICE
: Ceiling on process’s nice(2) value (number) (GNU/Linux).
:NOFILE
: File
descriptors (number) (SUSv3).
:NPROC
: Number of processes for the user (number) (4.4BSD, GNU/Linux).
:NPTS
: Number of pseudo terminals (number) (FreeBSD).
:RSS
: Resident memory size (bytes) (4.2BSD, GNU/Linux).
:RTPRIO
: Ceiling on the process’s real-time priority (number) (GNU/Linux).
:RTTIME
: CPU time for real-time process (us) (GNU/Linux).
:SBSIZE
: All socket buffers (bytes) (NetBSD, FreeBSD).
:SIGPENDING
: Number of queued signals allowed (signals) (GNU/Linux).
:STACK
: Stack size (bytes) (SUSv3).
Arguments cur_limit
and max_limit
may be:
Integers (max_limit
should not be smaller than cur_limit
).
Symbol
:SAVED_MAX
, string 'SAVED_MAX'
, or constant Process::RLIM_SAVED_MAX
: saved maximum limit.
Symbol
:SAVED_CUR
, string 'SAVED_CUR'
, or constant Process::RLIM_SAVED_CUR
: saved current limit.
Symbol
:INFINITY
, string 'INFINITY'
, or constant Process::RLIM_INFINITY
: no limit on resource.
This example raises the soft limit of core size to the hard limit to try to make core dump possible:
Process.setrlimit(:CORE, Process.getrlimit(:CORE)[1])
Not available on all platforms.
Detaches the current process from its controlling terminal and runs it in the background as system daemon; returns zero.
By default:
Changes the current working directory to the root directory.
Redirects $stdin, $stdout, and $stderr to the null device.
If optional argument nochdir
is true
, does not change the current working directory.
If optional argument noclose
is true
, does not redirect $stdin, $stdout, or $stderr.
Returns a Process::Tms
structure that contains user and system CPU times for the current process, and for its children processes:
Process.times # => #<struct Process::Tms utime=55.122118, stime=35.533068, cutime=0.0, cstime=0.002846>
The precision is platform-defined.
Returns the name of the script being executed. The value is not affected by assigning a new value to $0.
This method first appeared in Ruby 2.1 to serve as a global variable free means to get the script name.
Visit the interpolated content of the string-like node.