From 00f78058b64bdc8dd4f085bcd37bfb21961faa0e Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 26 May 2014 04:35:17 +0000 Subject: 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 --- ext/pty/pty.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'ext') diff --git a/ext/pty/pty.c b/ext/pty/pty.c index f54bbb52e5..ec255cf202 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; } -- cgit v1.2.3