summaryrefslogtreecommitdiff
path: root/process.c
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-20 07:39:32 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-20 07:39:32 +0000
commit51b72c10816af2791a7f89ec541f140a6b3fc447 (patch)
treea957464b0296925ad853bef9e9ed67a612ae9774 /process.c
parente62d2cb80c491a4337c1dfc6f580d06ea66b557e (diff)
parente1a45b10b6165c8fec505180a52c4ce58fb21e91 (diff)
add tag v1_9_0_2v1_9_0_2
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_9_0_2@17482 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'process.c')
-rw-r--r--process.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/process.c b/process.c
index ee0bbaf4d5..94dc712c8f 100644
--- a/process.c
+++ b/process.c
@@ -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;
}