summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-26 04:35:17 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-26 04:35:17 +0000
commit00f78058b64bdc8dd4f085bcd37bfb21961faa0e (patch)
tree04f06af56dc41163baaf459ead0d42d2fb064614 /ext
parentfba33accdbda1ef987dc7f1c1766ef379705094f (diff)
pty.c: do nothing if terminated already
* ext/pty/pty.c (pty_detach_process): if the child process has terminated already, return immediately without starting a thread to detach it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46129 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/pty/pty.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/ext/pty/pty.c b/ext/pty/pty.c
index f54bbb52e58..ec255cf2021 100644
--- a/ext/pty/pty.c
+++ b/ext/pty/pty.c
@@ -538,6 +538,11 @@ pty_open(VALUE klass)
static VALUE
pty_detach_process(struct pty_info *info)
{
+#ifdef WNOHANG
+ int st;
+ if (rb_waitpid(info->child_pid, &st, WNOHANG) <= 0)
+ return Qnil;
+#endif
rb_detach_process(info->child_pid);
return Qnil;
}