* process.c (detach_process_watcher): should not pass the pointer
to an auto variable to the thread to be created. pointed and fix by KUBO Takehiro <kubo at jiubao.org> [ruby-dev:30618] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13101 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
bade43f9d1
commit
6e0c6ac3be
@ -1,3 +1,9 @@
|
|||||||
|
Sat Aug 18 15:59:52 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* process.c (detach_process_watcher): should not pass the pointer
|
||||||
|
to an auto variable to the thread to be created. pointed and
|
||||||
|
fix by KUBO Takehiro <kubo at jiubao.org> [ruby-dev:30618]
|
||||||
|
|
||||||
Sat Aug 18 15:52:50 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Sat Aug 18 15:52:50 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* insnhelper.ci (vm_send_optimize): use MEMMOVE to shift values inside
|
* insnhelper.ci (vm_send_optimize): use MEMMOVE to shift values inside
|
||||||
|
16
process.c
16
process.c
@ -860,22 +860,21 @@ proc_waitall(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
detach_process_watcher(int *pid_p)
|
detach_process_watcher(void *arg)
|
||||||
{
|
{
|
||||||
rb_pid_t cpid;
|
rb_pid_t cpid, pid = (rb_pid_t)arg;
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
for (;;) {
|
while ((cpid = rb_waitpid(pid, &status, 0)) == 0) {
|
||||||
cpid = rb_waitpid(*pid_p, &status, WNOHANG);
|
/* wait while alive */
|
||||||
if (cpid != 0) return rb_last_status_get();
|
|
||||||
rb_thread_sleep(1);
|
|
||||||
}
|
}
|
||||||
|
return rb_last_status_get();
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
rb_detach_process(rb_pid_t pid)
|
rb_detach_process(rb_pid_t pid)
|
||||||
{
|
{
|
||||||
return rb_thread_create(detach_process_watcher, (void*)&pid);
|
return rb_thread_create(detach_process_watcher, (void*)pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -891,8 +890,7 @@ rb_detach_process(rb_pid_t pid)
|
|||||||
* separate Ruby thread whose sole job is to reap the status of the
|
* separate Ruby thread whose sole job is to reap the status of the
|
||||||
* process _pid_ when it terminates. Use <code>detach</code>
|
* process _pid_ when it terminates. Use <code>detach</code>
|
||||||
* 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.
|
||||||
* periodically (currently once each second).
|
|
||||||
*
|
*
|
||||||
* The waiting thread returns the exit status of the detached process
|
* The waiting thread returns the exit status of the detached process
|
||||||
* when it terminates, so you can use <code>Thread#join</code> to
|
* when it terminates, so you can use <code>Thread#join</code> to
|
||||||
|
Loading…
x
Reference in New Issue
Block a user