PATH:
opt
/
alt
/
ruby18
/
share
/
ri
/
1.8
/
system
/
Process
--- !ruby/object:RI::MethodDescription aliases: [] block_params: comment: - !ruby/struct:SM::Flow::P body: Some operating systems retain the status of terminated child processes until the parent collects that status (normally using some variant of <tt>wait()</tt>. If the parent never collects this status, the child stays around as a <em>zombie</em> process. <tt>Process::detach</tt> prevents this by setting up a separate Ruby thread whose sole job is to reap the status of the process <em>pid</em> when it terminates. Use <tt>detach</tt> only when you do not intent to explicitly wait for the child to terminate. <tt>detach</tt> only checks the status periodically (currently once each second). - !ruby/struct:SM::Flow::P body: The waiting thread returns the exit status of the detached process when it terminates, so you can use <tt>Thread#join</tt> to know the result. If specified <em>pid</em> is not a valid child process ID, the thread returns <tt>nil</tt> immediately. - !ruby/struct:SM::Flow::P body: In this first example, we don't reap the first child process, so it appears as a zombie in the process status display. - !ruby/struct:SM::Flow::VERB body: " p1 = fork { sleep 0.1 }\n p2 = fork { sleep 0.2 }\n Process.waitpid(p2)\n sleep 2\n system("ps -ho pid,state -p #{p1}")\n" - !ruby/struct:SM::Flow::P body: <em>produces:</em> - !ruby/struct:SM::Flow::VERB body: " 27389 Z\n" - !ruby/struct:SM::Flow::P body: In the next example, <tt>Process::detach</tt> is used to reap the child automatically. - !ruby/struct:SM::Flow::VERB body: " p1 = fork { sleep 0.1 }\n p2 = fork { sleep 0.2 }\n Process.detach(p1)\n Process.waitpid(p2)\n sleep 2\n system("ps -ho pid,state -p #{p1}")\n" - !ruby/struct:SM::Flow::P body: <em>(produces no output)</em> full_name: Process::detach is_singleton: true name: detach params: | Process.detach(pid) => thread visibility: public
[-] groups-c.yaml
[edit]
[-] groups%3d-c.yaml
[edit]
[-] initgroups-c.yaml
[edit]
[-] waitpid2-c.yaml
[edit]
[-] exit-c.yaml
[edit]
[-] maxgroups%3d-c.yaml
[edit]
[+]
Status
[-] maxgroups-c.yaml
[edit]
[-] wait2-c.yaml
[edit]
[-] waitpid-c.yaml
[edit]
[-] exec-c.yaml
[edit]
[+]
GID
[-] egid-c.yaml
[edit]
[-] exit%21-c.yaml
[edit]
[+]
UID
[-] setpriority-c.yaml
[edit]
[-] gid%3d-c.yaml
[edit]
[-] wait-c.yaml
[edit]
[-] egid%3d-c.yaml
[edit]
[-] fork-c.yaml
[edit]
[-] setpgrp-c.yaml
[edit]
[-] detach-c.yaml
[edit]
[-] kill-c.yaml
[edit]
[-] ppid-c.yaml
[edit]
[-] getpgrp-c.yaml
[edit]
[+]
Sys
[-] times-c.yaml
[edit]
[-] abort-c.yaml
[edit]
[-] euid-c.yaml
[edit]
[-] setsid-c.yaml
[edit]
[-] euid%3d-c.yaml
[edit]
[+]
..
[-] setpgid-c.yaml
[edit]
[-] getpriority-c.yaml
[edit]
[-] pid-c.yaml
[edit]
[-] uid%3d-c.yaml
[edit]
[-] uid-c.yaml
[edit]
[-] cdesc-Process.yaml
[edit]
[-] waitall-c.yaml
[edit]
[-] getpgid-c.yaml
[edit]
[-] getrlimit-c.yaml
[edit]
[-] gid-c.yaml
[edit]
[-] setrlimit-c.yaml
[edit]