| Server IP : 162.214.74.102 / Your IP : 216.73.217.21 Web Server : Apache System : Linux dedi-4363141.lrsys.com.br 3.10.0-1160.119.1.el7.tuxcare.els25.x86_64 #1 SMP Wed Oct 1 17:37:27 UTC 2025 x86_64 User : lrsys ( 1015) PHP Version : 5.6.40 Disable Function : exec,passthru,shell_exec,system MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /proc/self/root/proc/self/root/opt/cpanel/ea-ruby24/root/usr/share/ri/system/Process/ |
Upload File : |
U:RDoc::AnyMethod[iI"detach:ETI"Process::detach;TT:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"BSome operating systems retain the status of terminated child ;TI"Eprocesses until the parent collects that status (normally using ;TI"Hsome variant of <code>wait()</code>). If the parent never collects ;TI"Gthis status, the child stays around as a <em>zombie</em> process. ;TI"@<code>Process::detach</code> prevents this by setting up a ;TI"Fseparate Ruby thread whose sole job is to reap the status of the ;TI"?process _pid_ when it terminates. Use <code>detach</code> ;TI"Eonly when you do not intend to explicitly wait for the child to ;TI"terminate.;To:RDoc::Markup::BlankLine o;
; [ I"HThe waiting thread returns the exit status of the detached process ;TI"Dwhen it terminates, so you can use <code>Thread#join</code> to ;TI"Gknow the result. If specified _pid_ is not a valid child process ;TI".ID, the thread returns +nil+ immediately.;T@o;
; [I"JThe waiting thread has <code>pid</code> method which returns the pid.;T@o;
; [I"FIn this first example, we don't reap the first child process, so ;TI":it appears as a zombie in the process status display.;T@o:RDoc::Markup::Verbatim; [
I"p1 = fork { sleep 0.1 }
;TI"p2 = fork { sleep 0.2 }
;TI"Process.waitpid(p2)
;TI"
sleep 2
;TI")system("ps -ho pid,state -p #{p1}")
;T:@format0o;
; [I"<em>produces:</em>;T@o;; [I"
27389 Z
;T;
0o;
; [I"GIn the next example, <code>Process::detach</code> is used to reap ;TI"the child automatically.;T@o;; [I"p1 = fork { sleep 0.1 }
;TI"p2 = fork { sleep 0.2 }
;TI"Process.detach(p1)
;TI"Process.waitpid(p2)
;TI"
sleep 2
;TI")system("ps -ho pid,state -p #{p1}")
;T;
0o;
; [I""<em>(produces no output)</em>;T:
@fileI"process.c;T:0@omit_headings_from_table_of_contents_below0I"%Process.detach(pid) -> thread
;T0[ I" (p1);T@@FI"Process;TcRDoc::NormalModule00