diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-07-12 13:57:08 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-07-12 13:57:08 +0000 |
commit | b9fb3ee4b6d62c7026887e2b55aebaca6813d433 (patch) | |
tree | 92b809d5d84f8a776f0165d2d984f19c5c30f193 /ext | |
parent | dfcb5cf957a24184a607638d1c0d4cb2368ac5ca (diff) |
merges r23861 from trunk into ruby_1_9_1.
--
* ext/pty/pty.c (pty_getpty): check dup failure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@24040 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r-- | ext/pty/pty.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/ext/pty/pty.c b/ext/pty/pty.c index 0cefa221c4..7f5fd7d55c 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); |