Results for: "to_proc"

Waits for a suitable child process to exit, returns its process ID, and sets $? to a Process::Status object containing information on that process. Which child it waits for depends on the value of the given pid:

Argument flags should be given as one of the following constants, or as the logical OR of both:

Not all flags are available on all platforms.

Raises Errno::ECHILD if there is no suitable child process.

Not available on all platforms.

Process.waitpid is an alias for Process.wait.

Like Process.waitpid, but returns an array containing the child process pid and Process::Status status:

pid = Process.spawn('ruby', '-e', 'exit 13') # => 309581
Process.wait2(pid)
# => [309581, #<Process::Status: pid 309581 exit 13>]

Process.waitpid2 is an alias for Process.wait2.

Waits for all children, returns an array of 2-element arrays; each subarray contains the integer pid and Process::Status status for one of the reaped child processes:

pid0 = Process.spawn('ruby', '-e', 'exit 13') # => 325470
pid1 = Process.spawn('ruby', '-e', 'exit 14') # => 325495
Process.waitall
# => [[325470, #<Process::Status: pid 325470 exit 13>], [325495, #<Process::Status: pid 325495 exit 14>]]

Avoids the potential for a child process to become 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.

This method is needed only when the parent process will never wait for the child process.

This example does not reap the second child process; that process appears as a zombie in the process status (ps) output:

pid = Process.spawn('ruby', '-e', 'exit 13') # => 312691
sleep(1)
# Find zombies.
system("ps -ho pid,state -p #{pid}")

Output:

312716 Z

This example also does not reap the second child process, but it does detach the process so that it does not become a zombie:

pid = Process.spawn('ruby', '-e', 'exit 13') # => 313213
thread = Process.detach(pid)
sleep(1)
# => #<Process::Waiter:0x00007f038f48b838 run>
system("ps -ho pid,state -p #{pid}")        # Finds no zombies.

The waiting thread can return the pid of the detached child process:

thread.join.pid                       # => 313262

Returns the process ID of the current process:

Process.pid # => 15668

Returns the process ID of the parent of the current process:

puts "Pid is #{Process.pid}."
fork { puts "Parent pid is #{Process.ppid}." }

Output:

Pid is 271290.
Parent pid is 271290

May not return a trustworthy value on certain platforms.

Returns the process group ID for the current process:

Process.getpgid(0) # => 25527
Process.getpgrp    # => 25527

Equivalent to setpgid(0, 0).

Not available on all platforms.

Returns the process group ID for the given process ID +pid+:

  Process.getpgid(Process.ppid) # => 25527

Not available on all platforms.

Sets the process group ID for the process given by process ID pid to pgid.

Not available on all platforms.

Returns the session ID of the given process ID pid, or of the current process if not given:

Process.getsid                # => 27422
Process.getsid(0)             # => 27422
Process.getsid(Process.pid()) # => 27422

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.

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:

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):

Arguments cur_limit and max_limit may be:

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.

Returns the (real) user ID of the current process.

Process.uid # => 1000

Sets the (user) user ID for the current process to new_uid:

Process.uid = 1000 # => 1000

Not available on all platforms.

Returns the (real) group ID for the current process:

Process.gid # => 1000

Sets the group ID for the current process to new_gid:

Process.gid = 1000 # => 1000

Returns the effective user ID for the current process.

Process.euid # => 501

Sets the effective user ID for the current process.

Not available on all platforms.

Returns the effective group ID for the current process:

Process.egid # => 500

Not available on all platforms.

Sets the effective group ID for the current process.

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:

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.

Search took: 4ms  ·  Total Results: 1563