Module

Process

The Process module is a collection of methods used to manipulate processes.

Modules
GID The Process::GID module contains a collection of module functions which can be used to portably get, set, and switch the current process’s real, effective, and saved group IDs.
Sys The Process::Sys module contains UID and GID functions which provide direct bindings to the system calls of the same names instead of the more-portable versions of the same functionality found in the Process, Process::UID, and Process::GID modules.
UID The Process::UID module contains a collection of module functions which can be used to portably get, set, and switch the current process’s real, effective, and saved user IDs.
Classes
Status Process::Status encapsulates the information on the status of a running or terminated system process. The built-in variable $? is either nil or a Process::Status object.
Constants
PRIO_PGRP
PRIO_PROCESS
PRIO_USER
RLIMIT_AS
RLIMIT_CORE
RLIMIT_CPU
RLIMIT_DATA
RLIMIT_FSIZE
RLIMIT_MEMLOCK
RLIMIT_NOFILE
RLIMIT_NPROC
RLIMIT_RSS
RLIMIT_SBSIZE
RLIMIT_STACK
RLIM_INFINITY
RLIM_SAVED_CUR
RLIM_SAVED_MAX
WNOHANG
WNOHANG
WUNTRACED
WUNTRACED
Public Methods
abort Terminate execution immediately, effectively by calling Kernel.exit(1). If msg is given, it is written to STDERR prior to terminating.
detach 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 intent to explicitly wait for the child to terminate. detach only checks the status periodically (currently once each second).
egid Returns the effective group ID for this process. Not available on all platforms.
egid= Sets the effective group ID for this process. Not available on all platforms.
euid Returns the effective user ID for this process.
euid= Sets the effective user ID for this process. Not available on all platforms.
exit Initiates the termination of the Ruby script by raising the SystemExit exception. This exception may be caught. The optional parameter is used to return a status code to the invoking environment.
exit! Exits the process immediately. No exit handlers are run. fixnum is returned to the underlying system as the exit status.
fork Creates a subprocess. If a block is specified, that block is run in the subprocess, and the subprocess terminates with a status of zero. Otherwise, the fork call returns twice, once in the parent, returning the process ID of the child, and once in the child, returning nil. The child process can exit using Kernel.exit! to avoid running any at_exit functions. The parent process should use Process.wait to collect the termination statuses of its children or use Process.detach to register disinterest in their status; otherwise, the operating system may accumulate zombie processes.
getpgid Returns the process group ID for the given process id. Not available on all platforms.
getpriority Gets the scheduling priority for specified process, process group, or user. kind indicates the kind of entity to find: one of Process::PRIO_PGRP, Process::PRIO_USER, or Process::PRIO_PROCESS. integer is an id indicating the particular process, process group, or user (an id of 0 means current). Lower priorities are more favorable for scheduling. Not available on all platforms.
getrlimit Gets the resource limit of the process. cur_limit means current (soft) limit and max_limit means maximum (hard) limit.
gid Returns the (real) group ID for this process.
gid= Sets the group ID for this process.
groups Get an Array of the gids of groups in the supplemental group access list for this process.
groups= Set the supplemental group access list to the given Array of group IDs.
initgroups 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.
kill Sends the given signal to the specified process id(s), or to the
maxgroups Returns the maximum number of gids allowed in the supplemental group access list.
maxgroups= Sets the maximum number of gids allowed in the supplemental group access list.
pid Returns the process id of this process. Not available on all platforms.
ppid Returns the process id of the parent of this process. Always returns 0 on NT. Not available on all platforms.
setpgid Sets the process group ID of pid (0 indicates this process) to integer. Not available on all platforms.
setpgrp Equivalent to setpgid(0,0). Not available on all platforms.
setpriority See Process#getpriority.
setrlimit Sets the resource limit of the process. cur_limit means current (soft) limit and max_limit means maximum (hard) limit.
setsid Establishes this process as a new session and process group leader, with no controlling tty. Returns the session id. Not available on all platforms.
times Returns a Tms structure (see Struct::Tms on page 388) that contains user and system CPU times for this process.
uid Returns the (real) user ID of this process.
uid= Sets the (integer) user ID for this process. Not available on all platforms.
wait 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:
wait2 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 SystemError if there are no child processes.
waitall Waits for all children, returning an array of pid/status pairs (where status is a Process::Status object).
waitpid 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:
waitpid2 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 SystemError if there are no child processes.
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.