⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.133
Server IP:
185.119.109.197
Server:
Linux managedhosting.chostar.me 5.15.0-160-generic #170-Ubuntu SMP Wed Oct 1 10:06:56 UTC 2025 x86_64
Server Software:
Apache
PHP Version:
8.1.33
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
usr
/
share
/
ri
/
3.0.0
/
system
/
Process
/
View File Name :
detach-c.ri
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
wait()
). If the parent never collects ;TI"Gthis status, the child stays around as a
zombie
process. ;TI"HProcess::detach prevents this by setting up a separate Ruby thread ;TI"Gwhose sole job is to reap the status of the process _pid_ when it ;TI"Gterminates. Use #detach only when you do not intend to explicitly ;TI"%wait for the child to terminate.;To:RDoc::Markup::BlankLine o; ; [ I"HThe waiting thread returns the exit status of the detached process ;TI"7when it terminates, so you can use Thread#join to ;TI"Gknow the result. If specified _pid_ is not a valid child process ;TI".ID, the thread returns +nil+ immediately.;T@o; ; [I">The waiting thread has #pid 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"
produces:
;T@o;; [I" 27389 Z ;T; 0o; ; [I":In the next example, Process::detach 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""
(produces no output)
;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