PHP 8.2.31
Preview: detach-c.yaml Size: 1.91 KB
/proc/thread-self/root/opt/alt/ruby18/share/ri/1.8/system/Process/detach-c.yaml

--- !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(&quot;ps -ho pid,state -p #{p1}&quot;)\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(&quot;ps -ho pid,state -p #{p1}&quot;)\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

Directory Contents

Dirs: 4 × Files: 38

Name Size Perms Modified Actions
GID DIR
- drwxr-xr-x 2024-03-03 22:50:13
Edit Download
Status DIR
- drwxr-xr-x 2024-03-03 22:50:13
Edit Download
Sys DIR
- drwxr-xr-x 2024-03-03 22:50:13
Edit Download
UID DIR
- drwxr-xr-x 2024-03-03 22:50:13
Edit Download
395 B lrw-r--r-- 2023-07-26 13:48:00
Edit Download
3.85 KB lrw-r--r-- 2023-07-26 13:48:00
Edit Download
1.91 KB lrw-r--r-- 2023-07-26 13:48:00
Edit Download
315 B lrw-r--r-- 2023-07-26 13:48:00
Edit Download
454 B lrw-r--r-- 2023-07-26 13:48:00
Edit Download
302 B lrw-r--r-- 2023-07-26 13:48:00
Edit Download
424 B lrw-r--r-- 2023-07-26 13:48:00
Edit Download
1.22 KB lrw-r--r-- 2023-07-26 13:48:00
Edit Download
421 B lrw-r--r-- 2023-07-26 13:48:00
Edit Download
1.35 KB lrw-r--r-- 2023-07-26 13:48:00
Edit Download
1.04 KB lrw-r--r-- 2023-07-26 13:48:00
Edit Download
421 B lrw-r--r-- 2023-07-26 13:48:00
Edit Download
433 B lrw-r--r-- 2023-07-26 13:48:00
Edit Download
863 B lrw-r--r-- 2023-07-26 13:48:00
Edit Download
868 B lrw-r--r-- 2023-07-26 13:48:00
Edit Download
269 B lrw-r--r-- 2023-07-26 13:48:00
Edit Download
416 B lrw-r--r-- 2023-07-26 13:48:00
Edit Download
536 B lrw-r--r-- 2023-07-26 13:48:00
Edit Download
417 B lrw-r--r-- 2023-07-26 13:48:00
Edit Download
837 B lrw-r--r-- 2023-07-26 13:48:00
Edit Download
963 B lrw-r--r-- 2023-07-26 13:48:00
Edit Download
330 B lrw-r--r-- 2023-07-26 13:48:00
Edit Download
399 B lrw-r--r-- 2023-07-26 13:48:00
Edit Download
368 B lrw-r--r-- 2023-07-26 13:48:00
Edit Download
609 B lrw-r--r-- 2023-07-26 13:48:00
Edit Download
366 B lrw-r--r-- 2023-07-26 13:48:00
Edit Download
299 B lrw-r--r-- 2023-07-26 13:48:00
Edit Download
605 B lrw-r--r-- 2023-07-26 13:48:00
Edit Download
2.41 KB lrw-r--r-- 2023-07-26 13:48:00
Edit Download
457 B lrw-r--r-- 2023-07-26 13:48:00
Edit Download
473 B lrw-r--r-- 2023-07-26 13:48:00
Edit Download
312 B lrw-r--r-- 2023-07-26 13:48:00
Edit Download
414 B lrw-r--r-- 2023-07-26 13:48:00
Edit Download
2.17 KB lrw-r--r-- 2023-07-26 13:48:00
Edit Download
772 B lrw-r--r-- 2023-07-26 13:48:00
Edit Download
878 B lrw-r--r-- 2023-07-26 13:48:00
Edit Download
2.18 KB lrw-r--r-- 2023-07-26 13:48:00
Edit Download
778 B lrw-r--r-- 2023-07-26 13:48:00
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).