Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Ruby Programming
Previous Page Home
module Process

Index:

egid egid= euid euid= exit! fork getpgid getpgrp getpriority gid gid= kill pid ppid setpgid setpgrp setpriority setsid uid uid= wait wait2 waitpid waitpid2


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

constants

PRIO_PGRP 1 Process Group priority.
PRIO_PROCESS 0 Process priority.
PRIO_USER 2 User priority.
WNOHANG 1 Do not block if no child has exited. Not available on all platforms.
WUNTRACED 2 Return stopped children as well. Not available on all platforms.

class methods
egid Process.egid -> aFixnum

Returns the effective group id for this process.

Process.egid 500

egid= Process.egid= aFixnum -> aFixnum

Sets the effective group id for this process.

euid Process.euid -> aFixnum

Returns the effective user id for this process.

Process.euid 501

euid= Process.euid= aFixnum

Sets the effective user id for this process. Not available on all platforms.

exit! Process.exit!( aFixnum=-1 )

Exits the process immediately. No exit handlers are run. aFixnum is returned to the underlying system as the exit status.

Process.exit!(0)

fork Process.fork [{ block } ] -> aFixnum or nil

See Kernel::fork on page 416.

getpgid Process.getpgid( anInteger ) -> anInteger

Returns the process group id for the given process id. Not available on all platforms.

Process.getpgid(Process.ppid()) 32438

getpgrp Process.getpgrp -> anInteger

Returns the process group id for this process. Not available on all platforms.

Process.getpgid(0) 32438
Process.getpgrp 32438

getpriority Process.getpriority( aKind, anInteger ) -> aFixnum

Gets the scheduling priority for specified process, process group, or user. aKind indicates the kind of entity to find: one of Process::PRIO_PGRP , Process::PRIO_USER , or Process::PRIO_PROCESS . anInteger 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.

Process.getpriority(Process::PRIO_USER, 0) 0
Process.getpriority(Process::PRIO_PROCESS, 0) 0

gid Process.gid -> aFixnum

Returns the group id for this process.

Process.gid 500

gid= Process.gid= aFixnum -> aFixnum

Sets the group id for this process.

kill Process.kill( aSignal, [ aPid ]+ ) -> aFixnum

Sends the given signal to the specified process id(s), or to the current process if aPid is zero. aSignal may be an integer signal number or a POSIX signal name (either with or without a SIG prefix). If aSignal is negative (or starts with a ``-'' sign), kills process groups instead of processes. Not all signals are available on all platforms.

trap("SIGHUP") { close_then_exit }
Process.kill("SIGHUP", 0)

pid Process.pid -> aFixnum

Returns the process id of this process. Not available on all platforms.

Process.pid 1488

ppid Process.ppid -> aFixnum

Returns the process id of the parent of this process. Always returns 0 on NT. Not available on all platforms.

print "I am ", Process.pid, "\n"
Process.fork { print "Dad is ", Process.ppid, "\n" }
produces:
I am 1490
Dad is 1490

setpgid Process.setpgid( aPid, anInteger ) -> 0

Sets the process group id of aPid (0 indicates this process) to anInteger. Not available on all platforms.

setpgrp Process.setpgrp -> 0

Equivalent to setpgid(0,0). Not available on all platforms.

setpriority Process.setpriority( kind, anInteger, anIntPriority ) -> 0

See Process#getpriority .

Process.setpriority(Process::PRIO_USER, 0, 19) 0
Process.setpriority(Process::PRIO_PROCESS, 0, 19) 0
Process.getpriority(Process::PRIO_USER, 0) 19
Process.getpriority(Process::PRIO_PROCESS, 0) 19

setsid Process.setsid -> aFixnum

Establishes this process as a new session and process group leader, with no controlling tty. Returns the session id. Not available on all platforms.

Process.setsid 1495

uid Process.uid -> aFixnum

Returns the user id of this process.

Process.uid 501

uid= Process.uid= anInteger -> aNumeric

Sets the (integer) user id for this process. Not available on all platforms.

wait Process.wait -> aFixnum

Waits for any child process to exit and returns the process id of that child. Raises a SystemError if there are no child processes. Not available on all platforms.

Process.fork { exit 1; } 1500
Process.wait 1500

wait2 Process.wait2 -> anArray

Waits for any child process to exit and returns an array containing the process id and the exit status of that child. Raises a SystemError if there are no child processes.

Process.fork { exit 1 } 1503
Process.wait2 [1503, 256]

waitpid Process.waitpid( aPid, anInteger=0 ) -> aPid

Waits for the given child process to exit. anInteger may be a logical or of the flag value 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.

include Process
pid = fork { sleep 3 } 1506
Time.now Sun Jun 09 00:20:09 CDT 2002
waitpid(pid, Process::WNOHANG) nil
Time.now Sun Jun 09 00:20:09 CDT 2002
waitpid(pid, 0) 1506
Time.now Sun Jun 09 00:20:12 CDT 2002

waitpid2 Process.waitpid2( aPid, anInteger=0 ) -> anArray

Waits for the given child process to exit, returning that child's process id and exit status. anInteger may be a logical or of the flag value 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.


Ruby Programming
Previous Page Home

 
 
  Published under the terms of the Open Publication License Design by Interspire