Basically a wrapper for Process.spawn
that:
Creates a child process for each of the given cmds
by calling Process.spawn
.
Pipes the stdout
from each child to the stdin
of the next child, or, for the last child, to the caller’s stdout
.
Waits for the child processes to exit.
Returns an array of Process::Status
objects (one for each child).
Example:
wait_threads = Open3.pipeline('ls', 'grep R') # => [#<Process::Status: pid 2139200 exit 0>, #<Process::Status: pid 2139202 exit 0>]
Output:
Rakefile README.md
Like Process.spawn
, this method has potential security vulnerabilities if called with untrusted input; see Command Injection.
If the first argument is a hash, it becomes leading argument env
in each call to Process.spawn
; see Execution Environment.
If the last argument is a hash, it becomes trailing argument options
in each call to Process.spawn
‘ see Execution Options.
Each remaining argument in cmds
is one of:
A command_line
: a string that begins with a shell reserved word or special built-in, or contains one or more metacharacters.
An exe_path
: the string path to an executable to be called.
An array containing a command_line
or an exe_path
, along with zero or more string arguments for the command.
Basically a wrapper for Process.spawn
that:
Creates a child process for each of the given cmds
by calling Process.spawn
.
Pipes the stdout
from each child to the stdin
of the next child, or, for the last child, to the caller’s stdout
.
Waits for the child processes to exit.
Returns an array of Process::Status
objects (one for each child).
Example:
wait_threads = Open3.pipeline('ls', 'grep R') # => [#<Process::Status: pid 2139200 exit 0>, #<Process::Status: pid 2139202 exit 0>]
Output:
Rakefile README.md
Like Process.spawn
, this method has potential security vulnerabilities if called with untrusted input; see Command Injection.
If the first argument is a hash, it becomes leading argument env
in each call to Process.spawn
; see Execution Environment.
If the last argument is a hash, it becomes trailing argument options
in each call to Process.spawn
‘ see Execution Options.
Each remaining argument in cmds
is one of:
A command_line
: a string that begins with a shell reserved word or special built-in, or contains one or more metacharacters.
An exe_path
: the string path to an executable to be called.
An array containing a command_line
or an exe_path
, along with zero or more string arguments for the command.
Returns the singleton instance.
Returns a 2-element array of the current (soft) limit and maximum (hard) limit for the given resource
.
Argument resource
specifies the resource whose limits are to be returned; see Process.setrlimit
.
Each of the returned values cur_limit
and max_limit
is an integer; see Process.setrlimit
.
Example:
Process.getrlimit(:CORE) # => [0, 18446744073709551615]
See Process.setrlimit
.
Not available on all platforms.
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.
Specifies the handling of signals. The first parameter is a signal name (a string such as “SIGALRM”, “SIGUSR1”, and so on) or a signal number. The characters “SIG” may be omitted from the signal name. The command or block specifies code to be run when the signal is raised. If the command is the string “IGNORE” or “SIG_IGN”, the signal will be ignored. If the command is “DEFAULT” or “SIG_DFL”, the Ruby’s default handler will be invoked. If the command is “EXIT”, the script will be terminated by the signal. If the command is “SYSTEM_DEFAULT”, the operating system’s default handler will be invoked. Otherwise, the given command or block will be run. The special signal name “EXIT” or signal number zero will be invoked just prior to program termination. trap returns the previous handler for the given signal.
Signal.trap(0, proc { puts "Terminating: #{$$}" }) Signal.trap("CLD") { puts "Child died" } fork && Process.wait
produces:
Terminating: 27461 Child died Terminating: 27460
Returns a list of signal names mapped to the corresponding underlying signal numbers.
Signal.list #=> {"EXIT"=>0, "HUP"=>1, "INT"=>2, "QUIT"=>3, "ILL"=>4, "TRAP"=>5, "IOT"=>6, "ABRT"=>6, "FPE"=>8, "KILL"=>9, "BUS"=>7, "SEGV"=>11, "SYS"=>31, "PIPE"=>13, "ALRM"=>14, "TERM"=>15, "URG"=>23, "STOP"=>19, "TSTP"=>20, "CONT"=>18, "CHLD"=>17, "CLD"=>17, "TTIN"=>21, "TTOU"=>22, "IO"=>29, "XCPU"=>24, "XFSZ"=>25, "VTALRM"=>26, "PROF"=>27, "WINCH"=>28, "USR1"=>10, "USR2"=>12, "PWR"=>30, "POLL"=>29}
Returns the octet string representation of the elliptic curve point.
conversion_form specifies how the point is converted. Possible values are:
:compressed
:uncompressed
:hybrid
Iterates over strongly connected component in the subgraph reachable from node.
Return value is unspecified.
each_strongly_connected_component_from
doesn’t call tsort_each_node
.
class G include TSort def initialize(g) @g = g end def tsort_each_child(n, &b) @g[n].each(&b) end def tsort_each_node(&b) @g.each_key(&b) end end graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}) graph.each_strongly_connected_component_from(2) {|scc| p scc } #=> [4] # [2] graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}) graph.each_strongly_connected_component_from(2) {|scc| p scc } #=> [4] # [2, 3]
Iterates over strongly connected components in a graph. The graph is represented by node and each_child.
node is the first node. each_child should have call
method which takes a node argument and yields for each child node.
Return value is unspecified.
TSort.each_strongly_connected_component_from is a class method and it doesn’t need a class to represent a graph which includes TSort
.
graph = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]} each_child = lambda {|n, &b| graph[n].each(&b) } TSort.each_strongly_connected_component_from(1, each_child) {|scc| p scc } #=> [4] # [2, 3] # [1]
Returns value specified by the member name of VT_RECORD OLE object. If the member name is not correct, KeyError
exception is raised. If you can’t access member variable of VT_RECORD OLE object directly, use this method.
If COM server in VB.NET ComServer project is the following:
Imports System.Runtime.InteropServices Public Class ComClass Public Structure ComObject Public object_id As Ineger End Structure End Class
and Ruby Object
class has title attribute:
then accessing object_id of ComObject from Ruby is as the following:
srver = WIN32OLE.new('ComServer.ComClass') obj = WIN32OLE_RECORD.new('ComObject', server) # obj.object_id returns Ruby Object#object_id obj.ole_instance_variable_get(:object_id) # => nil
Sets value specified by the member name of VT_RECORD OLE object. If the member name is not correct, KeyError
exception is raised. If you can’t set value of member of VT_RECORD OLE object directly, use this method.
If COM server in VB.NET ComServer project is the following:
Imports System.Runtime.InteropServices Public Class ComClass <MarshalAs(UnmanagedType.BStr)> _ Public title As String Public cost As Integer End Class
then setting value of the ‘title’ member is as following:
srver = WIN32OLE.new('ComServer.ComClass') obj = WIN32OLE_RECORD.new('Book', server) obj.ole_instance_variable_set(:title, "The Ruby Book")
Compile a ConstantWriteNode
node
Dispatch enter and leave events for ConstantWriteNode
nodes and continue walking the tree.
Print stats and dump exit locations
If this boolean is true, the forward slashes will be escaped in the json output.
If this boolean is true, the forward slashes will be escaped in the json output.
This sets whether or not the forward slashes will be escaped in the json output.
Like Enumerable#zip
, but chains operation to be lazy-evaluated. However, if a block is given to zip, values are enumerated immediately.