* process.c (detach_process_watcher): return the last status.

[ruby-dev:22841]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5656 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2004-02-09 07:30:17 +00:00
Родитель 216a505751
Коммит 4f5b070378
2 изменённых файлов: 14 добавлений и 4 удалений

Просмотреть файл

@ -1,3 +1,8 @@
Mon Feb 9 16:30:12 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* process.c (detach_process_watcher): return the last status.
[ruby-dev:22841]
Sun Feb 8 16:46:08 2004 Nobuyoshi Nakada <nobu@ruby-lang.org> Sun Feb 8 16:46:08 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/pp.rb (PP::PPMethods::object_address_group): suppress negative * lib/pp.rb (PP::PPMethods::object_address_group): suppress negative

Просмотреть файл

@ -809,14 +809,14 @@ proc_waitall()
} }
static VALUE static VALUE
detach_process_watcer(pid_p) detach_process_watcher(pid_p)
int *pid_p; int *pid_p;
{ {
int cpid, status; int cpid, status;
for (;;) { for (;;) {
cpid = rb_waitpid(*pid_p, &status, WNOHANG); cpid = rb_waitpid(*pid_p, &status, WNOHANG);
if (cpid == -1) return Qnil; if (cpid == -1) return rb_last_status;
rb_thread_sleep(1); rb_thread_sleep(1);
} }
} }
@ -825,7 +825,7 @@ VALUE
rb_detach_process(pid) rb_detach_process(pid)
int pid; int pid;
{ {
return rb_thread_create(detach_process_watcer, (void*)&pid); return rb_thread_create(detach_process_watcher, (void*)&pid);
} }
@ -843,7 +843,12 @@ rb_detach_process(pid)
* only when you do not intent to explicitly wait for the child to * only when you do not intent to explicitly wait for the child to
* terminate. <code>detach</code> only checks the status * terminate. <code>detach</code> only checks the status
* periodically (currently once each second). * periodically (currently once each second).
* *
* The waiting thread returns the exit status of the detached process
* when it terminates, so you can use <code>Thread#join</code> to
* know the result. If specified _pid_ is not a valid child process
* ID, the thread returns +nil+ immediately.
*
* In this first example, we don't reap the first child process, so * In this first example, we don't reap the first child process, so
* it appears as a zombie in the process status display. * it appears as a zombie in the process status display.
* *