Gestionnaire de fichiers - Editer - /opt/cpanel/ea-ruby24/root/usr/share/ri/system/Process/detach-c.ri
Arrière
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
| ver. 1.4 |
Github
|
.
| PHP 8.0.30 | Génération de la page: 0.01 |
proxy
|
phpinfo
|
Réglages