diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-06-20 03:40:02 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-06-20 03:40:02 +0000 |
commit | 808fc9daa5538ae75ec06340a7c792dfdf72433e (patch) | |
tree | 2fccdbdeda98fd694db8b02a328ee9335570c040 /process.c | |
parent | 75fb0d37b351d989959c87bd2b54fa7837050f3f (diff) | |
download | ruby-808fc9daa5538ae75ec06340a7c792dfdf72433e.tar.gz ruby-808fc9daa5538ae75ec06340a7c792dfdf72433e.tar.xz ruby-808fc9daa5538ae75ec06340a7c792dfdf72433e.zip |
* process.c (rb_detach_process): store detached process ID in the
thread local storage. moved from lib/open3.rb.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@17469 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'process.c')
-rw-r--r-- | process.c | 19 |
1 files changed, 18 insertions, 1 deletions
@@ -885,6 +885,20 @@ proc_waitall(void) return result; } +static inline ID +id_pid(void) +{ + ID pid; + CONST_ID(pid, "pid"); + return pid; +} + +static VALUE +detach_process_pid(VALUE thread) +{ + return rb_thread_local_aref(thread, id_pid()); +} + static VALUE detach_process_watcher(void *arg) { @@ -900,7 +914,10 @@ detach_process_watcher(void *arg) VALUE rb_detach_process(rb_pid_t pid) { - return rb_thread_create(detach_process_watcher, (void*)(VALUE)pid); + VALUE watcher = rb_thread_create(detach_process_watcher, (void*)(VALUE)pid); + rb_thread_local_aset(watcher, id_pid(), PIDT2NUM(pid)); + rb_define_singleton_method(watcher, "pid", detach_process_pid, 0); + return watcher; } |