View Single Post
  #52 (permalink)  
Old 04-22-2008, 09:01 PM
shaalini shaalini is offline
D-Web Analyst
 
Join Date: Apr 2007
Posts: 342
shaalini is on a distinguished road
Default Re: Ruby BuiltIn functions

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
__________________
Shaalini.S
Be the Best of Whatever you are...
Reply With Quote