summaryrefslogtreecommitdiffstats
path: root/process.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-03-07 05:59:42 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-03-07 05:59:42 +0000
commit7590bd684f00ac8aad5e6f01728145f61ec1d0eb (patch)
tree842fe16738ccff2dee8b962b1ed71ddc0eda62c5 /process.c
parente9adbe3fc0c9c78637d9be2d97ac7360b545a05f (diff)
downloadruby-7590bd684f00ac8aad5e6f01728145f61ec1d0eb.tar.gz
ruby-7590bd684f00ac8aad5e6f01728145f61ec1d0eb.tar.xz
ruby-7590bd684f00ac8aad5e6f01728145f61ec1d0eb.zip
* parse.y (dsym): :"symbol string" style should not contain `\0'.
* process.c (proc_detach): new method Proc#detach(pid) which create background watcher thread to issue waitpid. [new] * process.c (rb_detach_process): utility function to detach process from C code. * ext/pty/pty.c (pty_finalize_syswait): terminate watcher thread, and detach child process (by creating new idle waitpid watcher thread). * ext/pty/pty.c (pty_syswait): may lost signal stopped child. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@3561 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'process.c')
-rw-r--r--process.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/process.c b/process.c
index 38cdfb096..3fc7f9e06 100644
--- a/process.c
+++ b/process.c
@@ -411,6 +411,33 @@ proc_waitall()
return result;
}
+static VALUE
+detach_process_watcer(pid_p)
+ int *pid_p;
+{
+ int cpid, status;
+
+ for (;;) {
+ cpid = rb_waitpid(*pid_p, &status, WNOHANG);
+ if (cpid == -1) return Qnil;
+ rb_thread_sleep(1);
+ }
+}
+
+void
+rb_detach_process(pid)
+ int pid;
+{
+ rb_thread_create(detach_process_watcer, (void*)&pid);
+}
+
+static VALUE
+proc_detach(obj, pid)
+ VALUE pid;
+{
+ rb_detach_process(NUM2INT(pid));
+}
+
#ifndef HAVE_STRING_H
char *strtok();
#endif
@@ -1319,6 +1346,7 @@ Init_process()
rb_define_module_function(rb_mProcess, "waitpid", proc_wait, -1);
rb_define_module_function(rb_mProcess, "waitpid2", proc_wait2, -1);
rb_define_module_function(rb_mProcess, "waitall", proc_waitall, 0);
+ rb_define_module_function(rb_mProcess, "detach", proc_detach, 1);
rb_cProcStatus = rb_define_class_under(rb_mProcess, "Status", rb_cObject);
rb_undef_method(CLASS_OF(rb_cProcStatus), "new");