ruby-changes:12183
From: akr <ko1@a...>
Date: Fri, 26 Jun 2009 22:02:03 +0900 (JST)
Subject: [ruby-changes:12183] Ruby:r23861 (trunk): * ext/pty/pty.c (pty_getpty): check dup failure.
akr 2009-06-26 22:01:16 +0900 (Fri, 26 Jun 2009) New Revision: 23861 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=23861 Log: * ext/pty/pty.c (pty_getpty): check dup failure. Modified files: trunk/ChangeLog trunk/ext/pty/pty.c Index: ChangeLog =================================================================== --- ChangeLog (revision 23860) +++ ChangeLog (revision 23861) @@ -1,3 +1,7 @@ +Fri Jun 26 21:48:30 2009 Tanaka Akira <akr@f...> + + * ext/pty/pty.c (pty_getpty): check dup failure. + Fri Jun 26 17:33:46 2009 Yukihiro Matsumoto <matz@r...> * test/ruby/test_rubyoptions.rb (TestRubyOptions#test_rubyopt): Index: ext/pty/pty.c =================================================================== --- ext/pty/pty.c (revision 23860) +++ ext/pty/pty.c (revision 23861) @@ -511,7 +511,27 @@ return Qnil; } -/* ruby function: getpty */ +/* + * call-seq: + * PTY.spawn(command...) {|r, w, pid| ... } => nil + * PTY.spawn(command...) => r, w, pid + * PTY.getpty(command...) {|r, w, pid| ... } => nil + * PTY.getpty(command...) => r, w, pid + * + * spawns the specified command on a newly allocated pty. + * + * The command's controlling tty is set to the slave device of the pty. + * Also its standard input/output/error is redirected to the slave device. + * + * PTY.spawn returns two IO objects and PID. + * PID is the process ID of the command. + * The two IO objects are connected to the master device of the pty. + * The first IO object is opened as read mode and + * The second is opened as write mode. + * + * If a block is given, two IO objects and PID is yielded. + * + */ static VALUE pty_getpty(int argc, VALUE *argv, VALUE self) { @@ -533,6 +553,8 @@ wfptr->mode = rb_io_mode_flags("w") | FMODE_SYNC; wfptr->fd = dup(info.fd); + if (wfptr->fd == -1) + rb_sys_fail("dup()"); wfptr->pathv = rfptr->pathv; res = rb_ary_new2(3); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/