APIdock / Ruby
/
method

waitall

ruby latest stable - Class: Process
waitall()
public

Waits for all children, returning an array of pid/status pairs (where status is a Process::Status object).

fork  { sleep 0.2; exit  2 } #=> 27432
fork  { sleep 0.1; exit  1 } #=> 27433
fork  { exit  0 } #=> 27434
p Process .waitall 

produces:

[[30982, #<Process::Status: pid 30982 exit 0>],
 [30979, #<Process::Status: pid 30979 exit 1>],
 [30976, #<Process::Status: pid 30976 exit 2>]]
static VALUE
proc_waitall(void)
{
 VALUE result;
 rb_pid_t pid;
 int status;
 result = rb_ary_new();
 rb_last_status_clear();
 for (pid = -1;;) {
 pid = rb_waitpid(-1, &status, 0);
 if (pid == -1) {
 int e = errno;
 if (e == ECHILD)
 break;
 rb_syserr_fail(e, 0);
 }
 rb_ary_push(result, rb_assoc_new(PIDT2NUM(pid), rb_last_status_get()));
 }
 return result;
}

AltStyle によって変換されたページ (->オリジナル) /