Some operating systems retain the status of terminated child processes until the parent collects that status (normally using some variant of wait()
). If the parent never collects this status, the child stays around as a zombie process. Process::detach
prevents this by setting up a separate Ruby thread whose sole job is to reap the status of the process pid when it terminates. Use detach
only when you do not intend to explicitly wait for the child to terminate.
The waiting thread returns the exit status of the detached process when it terminates, so you can use Thread#join
to know the result. If specified pid is not a valid child process ID, the thread returns nil
immediately.
The waiting thread has pid
method which returns the pid.
In this first example, we don’t reap the first child process, so it appears as a zombie in the process status display.
p1 = fork { sleep 0.1 } p2 = fork { sleep 0.2 } Process.waitpid(p2) sleep 2 system("ps -ho pid,state -p #{p1}")
produces:
27389 Z
In the next example, Process::detach
is used to reap the child automatically.
p1 = fork { sleep 0.1 } p2 = fork { sleep 0.2 } Process.detach(p1) Process.waitpid(p2) sleep 2 system("ps -ho pid,state -p #{p1}")
(produces no output)
Returns the maximum number of gids allowed in the supplemental group access list.
Process.maxgroups #=> 32
Sets the maximum number of gids allowed in the supplemental group access list.
Iterates through the child elements, yielding for each Element
that has a particular attribute set.
the name of the attribute to search for
the value of the attribute
(optional) causes this method to return after yielding for this number of matching children
(optional) if supplied, this is an XPath
that filters the children to check.
doc = Document.new "<a><b @id='1'/><c @id='2'/><d @id='1'/><e/></a>" # Yields b, c, d doc.root.each_element_with_attribute( 'id' ) {|e| p e} # Yields b, d doc.root.each_element_with_attribute( 'id', '1' ) {|e| p e} # Yields b doc.root.each_element_with_attribute( 'id', '1', 1 ) {|e| p e} # Yields d doc.root.each_element_with_attribute( 'id', '1', 0, 'd' ) {|e| p e}
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
.
Returns a Hash
containing the following keys:
Number of started SSL/TLS handshakes in server mode
Number of established SSL/TLS sessions in server mode
Number of start renegotiations in server mode
Number of sessions that were removed due to cache overflow
Number of successfully reused connections
Number of sessions proposed by clients that were not found in the cache
Number of sessions in the internal session cache
Number of sessions retrieved from the external cache in server mode
Number of started SSL/TLS handshakes in client mode
Number of established SSL/TLS sessions in client mode
Number of start renegotiations in client mode
Number of sessions proposed by clients that were found in the cache but had expired due to timeouts
Checks if ‘key’ is PRIV key for this cert
Takes the first digit of the reply code to determine the status type