Waits for a child process to exit (see Process::waitpid
for exact semantics) and returns an array containing the process id and the exit status (a Process::Status
object) of that child. Raises a SystemCallError
if there are no child processes.
Process.fork { exit 99 } #=> 27437 pid, status = Process.wait2 pid #=> 27437 status.exitstatus #=> 99
Waits for a child process to exit, returns its process id, and sets $?
to a Process::Status
object containing information on that process. Which child it waits on depends on the value of pid:
Waits for the child whose process ID equals pid.
Waits for any child whose process group ID equals that of the calling process.
Waits for any child process (the default if no pid is given).
Waits for any child whose process group ID equals the absolute value of pid.
The flags argument may be a logical or of the flag values Process::WNOHANG
(do not block if no child available) or Process::WUNTRACED
(return stopped children that haven’t been reported). Not all flags are available on all platforms, but a flag value of zero will work on all platforms.
Calling this method raises a SystemCallError
if there are no child processes. Not available on all platforms.
include Process fork { exit 99 } #=> 27429 wait #=> 27429 $?.exitstatus #=> 99 pid = fork { sleep 3 } #=> 27440 Time.now #=> 2008-03-08 19:56:16 +0900 waitpid(pid, Process::WNOHANG) #=> nil Time.now #=> 2008-03-08 19:56:16 +0900 waitpid(pid, 0) #=> 27440 Time.now #=> 2008-03-08 19:56:19 +0900
Waits for a child process to exit (see Process::waitpid
for exact semantics) and returns an array containing the process id and the exit status (a Process::Status
object) of that child. Raises a SystemCallError
if there are no child processes.
Process.fork { exit 99 } #=> 27437 pid, status = Process.wait2 pid #=> 27437 status.exitstatus #=> 99
Waits for all children, returning an array of pid/status pairs (where status is a Process::Status
object).
fork { sleep 0.2; exit 2 } #=> 27432 fork { sleep 0.1; exit 1 } #=> 27433 fork { exit 0 } #=> 27434 p Process.waitall
produces:
[[30982, #<Process::Status: pid 30982 exit 0>], [30979, #<Process::Status: pid 30979 exit 1>], [30976, #<Process::Status: pid 30976 exit 2>]]
Gets the resource limit of the process. cur_limit means current (soft) limit and max_limit means maximum (hard) limit.
resource indicates the kind of resource to limit. It is specified as a symbol such as :CORE
, a string such as "CORE"
or a constant such as Process::RLIMIT_CORE
. See Process.setrlimit
for details.
cur_limit and max_limit may be Process::RLIM_INFINITY
, Process::RLIM_SAVED_MAX
or Process::RLIM_SAVED_CUR
. See Process.setrlimit
and the system getrlimit(2) manual for details.
Sets the resource limit of the process. cur_limit means current (soft) limit and max_limit means maximum (hard) limit.
If max_limit is not given, cur_limit is used.
resource indicates the kind of resource to limit. It should be a symbol such as :CORE
, a string such as "CORE"
or a constant such as Process::RLIMIT_CORE
. The available resources are OS dependent. Ruby may support following resources.
total available memory (bytes) (SUSv3, NetBSD, FreeBSD, OpenBSD but 4.4BSD-Lite)
core size (bytes) (SUSv3)
CPU time (seconds) (SUSv3)
data segment (bytes) (SUSv3)
file size (bytes) (SUSv3)
total size for mlock(2) (bytes) (4.4BSD, GNU/Linux)
allocation for POSIX message queues (bytes) (GNU/Linux)
ceiling on process’s nice(2) value (number) (GNU/Linux)
file descriptors (number) (SUSv3)
number of processes for the user (number) (4.4BSD, GNU/Linux)
RSS
resident memory size (bytes) (4.2BSD, GNU/Linux)
ceiling on the process’s real-time priority (number) (GNU/Linux)
CPU time for real-time process (us) (GNU/Linux)
all socket buffers (bytes) (NetBSD, FreeBSD)
number of queued signals allowed (signals) (GNU/Linux)
stack size (bytes) (SUSv3)
cur_limit and max_limit may be :INFINITY
, "INFINITY"
or Process::RLIM_INFINITY
, which means that the resource is not limited. They may be Process::RLIM_SAVED_MAX
, Process::RLIM_SAVED_CUR
and corresponding symbols and strings too. See system setrlimit(2) manual for details.
The following 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])
Initializes the supplemental group access list by reading the system group database and using all groups of which the given user is a member. The group with the specified gid is also added to the list. Returns the resulting Array
of the gids of all the groups in the supplementary group access list. Not available on all platforms.
Process.groups #=> [0, 1, 2, 3, 4, 6, 10, 11, 20, 26, 27] Process.initgroups( "mgranger", 30 ) #=> [30, 6, 10, 11] Process.groups #=> [30, 6, 10, 11]
Detach the process from controlling terminal and run in the background as system daemon. Unless the argument nochdir is true (i.e. non false), it changes the current working directory to the root (“/”). Unless the argument noclose is true, daemon() will redirect standard input, standard output and standard error to /dev/null. Return zero on success, or raise one of Errno::*.
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.
See the OpenSSL
documentation for EC_GROUP_get_point_conversion_form()
See the OpenSSL
documentation for EC_GROUP_set_point_conversion_form()
Invoke the command with the given list of normal arguments and additional build arguments.
Adds a section with title
and content
to the parser help view. Used for adding command arguments and default arguments.
Remove everything in the DependencyList
that matches but doesn’t satisfy items in dependencies
(a hash of gem names to arrays of dependencies).
Enumerates the outdated local gems yielding the local specification and the latest remote version.
This method may take some time to return as it must check each local gem against the server’s index.
Sets up a fake fetcher using the gems from util_make_gems
. Optionally additional prerelease
gems may be included.
Gems created by this method may be fetched using Gem::RemoteFetcher
.
Sets up Gem::SpecFetcher
to return information from the gems in specs
. Best used with +@all_gems+ from util_setup_fake_fetcher
.