From 5f99b7ce58afd01c42fa81a1cb13fd1de30e3556 Mon Sep 17 00:00:00 2001 From: yugui Date: Sun, 12 Jul 2009 13:57:08 +0000 Subject: merges r23861 from trunk into ruby_1_9_1. -- * ext/pty/pty.c (pty_getpty): check dup failure. git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_9_1@24040 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ ext/pty/pty.c | 24 +++++++++++++++++++++++- version.h | 2 +- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index a2959b8a0..4971e7157 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Fri Jun 26 21:48:30 2009 Tanaka Akira + + * ext/pty/pty.c (pty_getpty): check dup failure. + Thu Jun 25 17:58:39 2009 Yukihiro Matsumoto * io.c (argf_binmode_m): should call rb_io_ascii8bit_binmode() to diff --git a/ext/pty/pty.c b/ext/pty/pty.c index 0cefa221c..7f5fd7d55 100644 --- a/ext/pty/pty.c +++ b/ext/pty/pty.c @@ -425,7 +425,27 @@ getDevice(int *master, int *slave, char SlaveName[DEVICELEN]) return; } -/* 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) { @@ -448,6 +468,8 @@ pty_getpty(int argc, VALUE *argv, VALUE self) 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); diff --git a/version.h b/version.h index 787abcc01..bf3cc49b2 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "1.9.1" #define RUBY_RELEASE_DATE "2009-06-25" -#define RUBY_PATCHLEVEL 206 +#define RUBY_PATCHLEVEL 207 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 9 #define RUBY_VERSION_TEENY 1 -- cgit