IO.sysdup2, IO.sysdup, IO.sysclose

redirect e$B$N=hM}$r$A$g$C$H=q$$$F$$?$H$3$m!"e(B
IO.sysdup2, IO.sysdup, IO.sysclose e$B$,M
$7$/$J$C$?$N$G$9$,!"e(B
e$B2C$($F$b$$$$$G$7$g$&$+!#e(B(e$B%I%-%e%a%s%H$O8e$G=q$-$^$9!#e(B)

e$BNc$($P!“e(Bsh e$B$Ne(B 3>&1 e$B$r<B8=$9$k$K$O$Oe(B dup2(1,3)
e$B$r8F$S=P$5$J$$e(B
e$B$H$$$1$J$$$o$1$G$9$,!“e(BIO#reopen e$B$G$3$l$r9T$&$K$O!”$^$:e(B fd
e$B$,e(B
3 e$B$Je(B IO e$B%*%V%8%’%/%H$r$($kI,MW$,$”$j$^$9!#$7$+$7!"e(B3 e$B$,e(B
close
e$B>uBV$@$H!"e(BIO.new e$B$,$G$-$^$;$s!#$G$Oe(B 3 e$B$r$I$&$K$+$7$Fe(B
open e$B>ue(B
e$BBV$Ke(B… e$B$H$+9M$($k$h$j$Oe(B dup2
e$B$,$$$-$J$j;H$($k$N$,NI$+$m$&!"e(B
e$B$H$$$&$o$1$G$9!#e(B

dup e$B$He(B sysclose e$B$O!"e(BIO
e$B%l%Y%k$G$d$k$3$H$b$G$-$^$9$,!"e(Bdup2 e$B$Ge(B
e$B$=$&$d$C$Fe(B fd e$B%l%Y%k$G$NA`:n$r9T$C$F$$$k$H!“e(BIO
e$B%l%Y%k$K;}$Ae(B
e$B>e$2$F$+$i:n6H$9$k$N$,LLE]$/$5$/!”$^$?!"e(BGC e$B$r5$$K$7$J$$$H$$e(B
e$B$1$J$/$F$$$d$J$N$,DI2C$NM}M3$G$9!#$=$l$K!“e(Bsysopen
e$B$O$9$G$K$”$Ce(B
e$B$F!"BP$K$J$ke(B sysclose e$B$,$J$$$He(B close e$B$7$K$/$$$G$9$7!#e(B

Index: io.c

— io.c (e$B%j%S%8%g%se(B 13236)
+++ io.c (e$B:n6H%3%T!<e(B)
@@ -5143,6 +5143,43 @@
#endif
}

+static VALUE
+rb_io_s_sysdup(VALUE klass, VALUE oldfd_v)
+{

  • int oldfd, ret;
  • oldfd = NUM2INT(oldfd_v);
  • ret = dup(oldfd);
  • if (ret == -1) {
  •    rb_sys_fail(0);
    
  • }
  • return INT2NUM(ret);
    +}

+static VALUE
+rb_io_s_sysdup2(VALUE klass, VALUE oldfd_v, VALUE newfd_v)
+{

  • int oldfd, newfd, ret;
  • oldfd = NUM2INT(oldfd_v);
  • newfd = NUM2INT(newfd_v);
  • ret = dup2(oldfd, newfd);
  • if (ret == -1) {
  •    rb_sys_fail(0);
    
  • }
  • return INT2NUM(ret);
    +}

+static VALUE
+rb_io_s_sysclose(VALUE klass, VALUE fd_v)
+{

  • int fd, ret;
  • fd = NUM2INT(fd_v);
  • ret = close(fd);
  • if (ret == -1) {
  •    rb_sys_fail(0);
    
  • }
  • return INT2NUM(ret);
    +}

struct foreach_arg {
int argc;
VALUE *argv;
@@ -5708,6 +5745,9 @@
rb_define_singleton_method(rb_cIO, “read”, rb_io_s_read, -1);
rb_define_singleton_method(rb_cIO, “select”, rb_f_select, -1);
rb_define_singleton_method(rb_cIO, “pipe”, rb_io_s_pipe, 0);

  • rb_define_singleton_method(rb_cIO, “sysdup”, rb_io_s_sysdup, 1);

  • rb_define_singleton_method(rb_cIO, “sysdup2”, rb_io_s_sysdup2, 2);

  • rb_define_singleton_method(rb_cIO, “sysclose”, rb_io_s_sysclose,
    1);

    rb_define_method(rb_cIO, “initialize”, rb_io_initialize, -1);

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:31625] IO.sysdup2, IO.sysdup, IO.sysclose”
on Fri, 24 Aug 2007 00:04:56 +0900, Tanaka A. [email protected]
writes:

|redirect e$B$N=hM}$r$A$g$C$H=q$$$F$$?$H$3$m!"e(B
|IO.sysdup2, IO.sysdup, IO.sysclose e$B$,M
$7$/$J$C$?$N$G$9$,!"e(B
|e$B2C$($F$b$$$$$G$7$g$&$+!#e(B(e$B%I%-%e%a%s%H$O8e$G=q$-$^$9!#e(B)

sysclosee$B$O$^$"$$$$$H$7$F!“e(Bdup, dup2e$B$H$J$k$H$I$&$J$N$+$J$”!#e(B
e$B$=$m$=$m!"e(Bdle$B$+3HD%%i%$%V%i%j$G<B8=$7$F$[$7$$$h$&$J!#e(Bfstate$B$H$+e(B
ftruncatee$B$H$+!"M_$7$$$N$,<!!9A}$($=$&$G!#e(B

e$B$=$NJU$N4p=`$,L@3N$G$“$l$P!”$=$l0J>e$NH?BP$O$7$^$;$s!#e(B

In article E1IOaVr-0001Yu-4H@x31,
Yukihiro M. [email protected] writes:

sysclosee$B$O$^$"$$$$$H$7$F!“e(Bdup, dup2e$B$H$J$k$H$I$&$J$N$+$J$”!#e(B
e$B$=$m$=$m!"e(Bdle$B$+3HD%%i%$%V%i%j$G<B8=$7$F$[$7$$$h$&$J!#e(Bfstate$B$H$+e(B
ftruncatee$B$H$+!"M_$7$$$N$,<!!9A}$($=$&$G!#e(B

IO::FD e$B%/%i%9$r:n$C$F!“$=$N%$%s%9%?%s%9%a%=%C%I$KF~$l$k$H$$e(B
e$B$&JL$N0F$b$”$j$^$9!#e(B

IO::FD.new(1).dup2(3) e$B$Ge(B dup2(1,3) e$B$H$+!#e(B

e$B$=$&$$$&3HD%%i%$%V%i%j$rF~$l$F$$$$$G$9$+e(B?

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:31641] Re: IO.sysdup2, IO.sysdup, IO.sysclose”
on Fri, 24 Aug 2007 23:58:57 +0900, Tanaka A. [email protected]
writes:

|IO::FD e$B%/%i%9$r:n$C$F!“$=$N%$%s%9%?%s%9%a%=%C%I$KF~$l$k$H$$e(B
|e$B$&JL$N0F$b$”$j$^$9!#e(B
|
|IO::FD.new(1).dup2(3) e$B$Ge(B dup2(1,3) e$B$H$+!#e(B

sysopen, sysclosee$B$r%Y!<%9$Ke(BFixnume$B$r;H$C$?4X?t%Y!<%9$GA`:n$9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e$B$9$kI,MW$O$^$:$J$$$H$O;We(B
e$B$$$^$9$,!#e(B

e$B%*%V%8%'%/%H$NMxE@$O!“e(Bfile descriptor e$B$r@0?t$H6hJL$9$k$3$H$Ge(B
e$B$9$+$M!#e(Bfile descriptor e$B$G$”$k$H$$$&0U?^$rI=8=$9$k$N$KJXMx$Ge(B
e$B$9!#e(B

e$B2a5n$K3HD%%i%$%V%i%j$r<h$j9~$s$@7P0^$@$H!"$^$:<j85$GF0$/$b$Ne(B
e$B$r:n$C$F<B:]$K;H$C$F$$$?$@$$$F$+$i!“H=CG$7$F$$$?$h$&$K;W$$$^e(B
e$B$9!#8=;~E@$G$OI8=`E:IU$K$9$Y$-$+!”$=$l$H$be(Bgeme$B$GDs6!$9$kDxEY$Ge(B
e$B==J,$J$N$+H=CG$K:$$j$^$9!#e(B

e$B$?$7$+$K!#e(B

e$B$?$@!“$d$j$?$$$3$H$Oe(B shell e$B$G4JC1$K$G$-$kOC$J$N$G!”$=$N$/$ie(B
e$B$$$OI8=`$G$G$-$F$[$7$$$H;W$$$^$9!#$^$?!“$3$N$”$?$j$Oe(B POSIX
e$B$GDj5A$5$l$F$$$kHO0O$G$9$7!#e(B

Index: ext/io/fd/extconf.rb

— ext/io/fd/extconf.rb (e$B%j%S%8%g%se(B 0)
+++ ext/io/fd/extconf.rb (e$B%j%S%8%g%se(B 0)
@@ -0,0 +1,3 @@
+require ‘mkmf’
+
+create_makefile(“io/fd”)
Index: ext/io/fd/fd.c

— ext/io/fd/fd.c (e$B%j%S%8%g%se(B 0)
+++ ext/io/fd/fd.c (e$B%j%S%8%g%se(B 0)
@@ -0,0 +1,227 @@
+#include “ruby.h”
+#include “rubyio.h”
+#include <unistd.h>
+
+static VALUE FD;
+
+static void
+fd_mark(void *ptr)
+{
+}
+
+static void
+fd_free(void *ptr)
+{
+}
+
+static VALUE
+fd_s_allocate(VALUE klass)
+{

  • return Data_Wrap_Struct(klass, fd_mark, fd_free, (void*)-1);
    +}

+static VALUE
+fd_new(int fd)
+{

  • VALUE v = fd_s_allocate(FD);
  • DATA_PTR(v) = (void*)fd;
  • return v;
    +}

+#define IS_FD(obj) (RDATA(obj)->dmark == (RUBY_DATA_FUNC)fd_mark)
+
+static int
+check_fd(VALUE self)
+{

  • Check_Type(self, T_DATA);
  • if (!IS_FD(self)) {
  •    rb_raise(rb_eTypeError, "wrong argument type %s (expected 
    

IO::FD)",

  •             rb_class2name(CLASS_OF(self)));
    
  • }
  • return (int)DATA_PTR(self);
    +}

+static int
+get_fd(VALUE v)
+{

  • switch (TYPE(v)) {
  •  case T_DATA:
    
  •    return check_fd(v);
    
  •  case T_FIXNUM:
    
  •    return FIX2INT(v);
    
  •  default:
    
  •    return NUM2INT(rb_to_int(v));
    
  • }
    +}

+/*

    • call-seq: IO::FD.new(fd)
    • returns newly created IO::FD object.
  • */

+static VALUE
+fd_initialize(VALUE self, VALUE fd_v)
+{

  • DATA_PTR(self) = get_fd(fd_v);
  • return self;
    +}

+/*

    • returns the file descriptor as an integer.
    • IO::FD.new(10).to_i #=> 10
  • */

+static VALUE
+fd_to_i(VALUE self)
+{

  • return INT2NUM((int)DATA_PTR(self));
    +}

+static VALUE
+fd_inspect(VALUE self)
+{

  • return rb_sprintf(“#IO::FD:%d”, (int)DATA_PTR(self));
    +}

+/*

    • invokes dup system call.
    • It returns newly created IO::FD object for the duplicated file
      descriptor.
  • */

+static VALUE
+fd_dup(VALUE oldfd_v)
+{

  • int oldfd, ret;
  • oldfd = get_fd(oldfd_v);
  • ret = dup(oldfd);
  • if (ret == -1) {
  •    rb_sys_fail(0);
    
  • }
  • return fd_new(ret);
    +}

+/*

    • call-seq: IO::FD.dup(fd)
    • invokes dup system call.
    • It returns newly created IO::FD object for the duplicated file
      descriptor.
    • fd should be an IO::FD object or an integer.
  • */

+static VALUE
+fd_s_dup(VALUE klass, VALUE oldfd_v)
+{

  • return fd_dup(oldfd_v);
    +}

+/*

    • call-seq: dup2(newfd)
    • invokes dup2 system call.
    • It returns newly created IO::FD object for the duplicated file
      descriptor.
    • newfd should be an IO::FD object or an integer.
  • */

+static VALUE
+fd_dup2(VALUE oldfd_v, VALUE newfd_v)
+{

  • int oldfd, newfd, ret;
  • oldfd = get_fd(oldfd_v);
  • newfd = get_fd(newfd_v);
  • ret = dup2(oldfd, newfd);
  • if (ret == -1) {
  •    rb_sys_fail(0);
    
  • }
  • return fd_new(ret);
    +}

+/*

    • call-seq: IO::FD.dup2(oldfd, newfd)
    • invokes dup2 system call.
    • It returns newly created IO::FD object for the duplicated file
      descriptor.
    • oldfd and newfd should be an IO::FD object or an integer.
  • */

+static VALUE
+fd_s_dup2(VALUE klass, VALUE oldfd_v, VALUE newfd_v)
+{

  • return fd_dup2(oldfd_v, newfd_v);
    +}

+/*

    • invokes close system call.
    • It returns nil.
    • IO::FD.new(5).close #=> nil
  • */

+static VALUE
+fd_close(VALUE fd_v)
+{

  • int fd, ret;
  • fd = get_fd(fd_v);
  • ret = close(fd);
  • if (ret == -1) {
  •    rb_sys_fail(0);
    
  • }
  • return Qnil;
    +}

+/*

    • call-seq: IO::FD.close(fd)
    • invokes close system call.
    • It returns nil.
    • fd should be an IO::FD object or an integer.
    • IO::FD.close(5) #=> nil
  • */

+static VALUE
+fd_s_close(VALUE klass, VALUE fd_v)
+{

  • return fd_close(fd_v);
    +}

+/*

    • IO::FD class
  • */

+void
+Init_fd()
+{

  • FD = rb_define_class_under(rb_cIO, “FD”, rb_cData);
  • rb_define_alloc_func(FD, fd_s_allocate);
  • rb_define_singleton_method(FD, “dup”, fd_s_dup, 1);
  • rb_define_singleton_method(FD, “dup2”, fd_s_dup2, 2);
  • rb_define_singleton_method(FD, “close”, fd_s_close, 1);
  • rb_define_method(FD, “initialize”, fd_initialize, 1);
  • rb_define_method(FD, “to_i”, fd_to_i, 0);
  • rb_define_method(FD, “inspect”, fd_inspect, 0);
  • rb_define_method(FD, “dup”, fd_dup, 0);
  • rb_define_method(FD, “dup2”, fd_dup2, 1);
  • rb_define_method(FD, “close”, fd_close, 0);
    +}

e$B$3$s$P$s$O!"e(Bsheepman e$B$G$9!#e(B

Ruby e$B$G$Ne(B dup2
e$B$NI,MW@-$H$$$&$N$,NI$/J,$+$i$J$$$N$G<ALd$5$;$F2<$5$$!#e(B

e$BNc$($P!“e(Bsh e$B$Ne(B 3>&1 e$B$r<B8=$9$k$K$O$Oe(B dup2(1,3) e$B$r8F$S=P$5$J$$e(B
e$B$H$$$1$J$$$o$1$G$9$,!“e(BIO#reopen e$B$G$3$l$r9T$&$K$O!”$^$:e(B fd e$B$,e(B
3 e$B$Je(B IO e$B%*%V%8%’%/%H$r$($kI,MW$,$”$j$^$9!#$7$+$7!"e(B3 e$B$,e(B close
e$B>uBV$@$H!"e(BIO.new e$B$,$G$-$^$;$s!#$G$Oe(B 3 e$B$r$I$&$K$+$7$Fe(B open e$B>ue(B
e$BBV$Ke(B… e$B$H$+9M$($k$h$j$Oe(B dup2 e$B$,$$$-$J$j;H$($k$N$,NI$+$m$&!"e(B
e$B$H$$$&$o$1$G$9!#e(B

sh e$B$J$I$G$Ne(B 3>&1 e$B$Ne(B 3
e$B$H$$$&$N$O0l;~JQ?t$_$?$$$J$b$N$J$N$G!"e(B
3 e$B$r6qBNE*$K;XDj$G$-$kI,MW@-$O$J$$$O$:$G$9!#Nc$($P!"e(B

$ command 3>&1 >/dev/null 2>&3

e$B$_$?$$$J$3$H$re(B Ruby e$B$G$7$?$$$H$-$Oe(B

fd3 = $stdout.dup
$stdout.reopen(’/dev/null’)
$stderr.reopen(fd3)

e$B$H$9$l$PNI$$$N$G$O$H;W$&$N$G$9$,!#e(Bfd
e$B$r6qBNE*$K;XDj$G$-$?J}$,$&$l$7$$$N$Oe(B
e$B$I$&$$$C$?$P$"$$$G$7$g$&$+e(B?

In article [email protected],
sheepman [email protected] writes:

e$B$H$9$l$PNI$$$N$G$O$H;W$&$N$G$9$,!#e(Bfd e$B$r6qBNE*$K;XDj$G$-$?J}$,$&$l$7$$$N$Oe(B
e$B$I$&$$$C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J$b$N$r$<$se(B
e$B$Ve(B close e$B$9$k$H$9$l$P$G$-$J$/$O$”$j$^$;$s$,!”$=$l$O$+$J$j1*e(B
e$B1s$G$9$h$M!#0lHiGm$1$Pe(B dup2 e$B$,$“$k$N$K!”$J$s$G$=$s$J6lO+$r$7e(B
e$B$J$$$H$$$1$J$$$N$@$m$&$+!"$H;W$C$F$7$^$$$^$9!#e(B

In article [email protected],
Tanaka A. [email protected] writes:

e$B$J$k$[$I!"$=$&$+$b$7$l$^$;$s!#N>J}:n$C$F$_$^$7$?!#e(B

e$B$b$&$R$H$De(B API e$B$N%“%$%G%”$r;W$$IU$-$^$7$?!#e(B

e$B:#2s$N7o$Ge(B IO e$B$Ge(B fd e$B$r07$$$?$/$J$$LdBj$O!"e(B

  • open e$B$5$l$F$$$J$$e(B fd e$B$KBP1~$9$ke(B IO e$B$r:n$l$J$$e(B
  • GC e$B$Ge(B close e$B$5$l$F$7$^$&e(B
  • reopen e$B$,e(B mode e$B$,860x$G<:GT$9$k$3$H$,$“$ke(B
    e$B$H$$$&$H$3$m$K$”$j$^$9!#e(B

e$B$J$N$G!"e(B

  • IO.new!(fd) e$B$de(B IO.sysnew(fd) e$B$H$+$r:n$C$F!"e(Bopen
    e$B$5$l$F$$$Je(B
    e$B$$e(B fd e$B$KBP1~$9$ke(B IO e$B%*%V%8%'%/%H$r:n$l$k$h$&$K$9$ke(B
  • IO#close_on_gc = false e$B$H$+$r$G$-$k$h$&$K$7$F!"e(BGC e$B;~$Ne(B
    close e$B$rM^@)$G$-$k$h$&$K$9$ke(B
  • IO.dup2(oldio, newio) e$B$r?7@_$9$ke(B
    e$B$H$$$&$N$O$I$&$G$7$g$&$+!#e(B

e$B$J$!"e(BIO.dup2 e$B$Ne(B oldio, newio e$B$Oe(B IO
e$B%
%V%8%‘%/%H$b$7$/$O@0?te(B
e$B$G!"e(Bmode e$B$r5$$K$;$:F0:n$9$k$b$N$H$7$^$9!#e(BIO
e$B%*%V%8%’%/%H$r07e(B
e$B$($k$N$GL>A0$Ke(B sys e$B$O$D$1$^$;$s!#e(B

e$B$"$H!"e(BIO#close_on_gc e$B$O!"8=:_$*$3$J$C$F$$$ke(B STDIN, STDOUT,
STDERR e$B$Ne(B close e$B$5$l$J$$FCJL07$$$r$$$/$i$+8:$i$9$3$H$,$G$-$ke(B
e$B$H$$$&E@$G$b$h$m$7$$$s$8$c$J$$$+$H;W$$$^$9!#e(B

e$B$3$s$P$s$Oe(B sheepman e$B$G$9!#e(B

e$B$4@bL@$"$j$,$H$&$4$6$$$^$9!#e(Bfd
e$B$rD>@;XDj$9$k;H$$J}$,B8:_$9$ke(B
e$B$H$$$&$3$H$r$O$8$a$FCN$j$^$7$?!#JY6/$K$J$j$^$7$?!#e(B

On Sat, 1 Sep 2007 17:39:51 +0900

In article [email protected],
sheepman [email protected] writes:

e$B$4@bL@$"$j$,$H$&$4$6$$$^$9!#e(Bfd e$B$rD>@;XDj$9$k;H$$J}$,B8:_$9$ke(B
e$B$H$$$&$3$H$r$O$8$a$FCN$j$^$7$?!#JY6/$K$J$j$^$7$?!#e(B

e$B$$$d$^$!!“$?$7$+$K0l;~JQ?t$N$h$&$J;H$$$+$?$N$[$&$,$:$C$HB?$$e(B
e$B$N$O3N$+$G$9$+$i!”$=$C$A$NMQK!$K$D$$$F$O6qBNE*$JHV9f$r=q$+$Je(B
e$B$$$G$bK>$`$3$H$,<B8=$G$-$k$h$&$J;Y1g$,=EMW$@$H;W$$$^$9!#e(B

dup2 e$B$H$+!"e(Bsh e$B$Ne(B redirect
e$B$HF1$85!G=$H$$$&$@$1$G$O$^$@$^$@;He(B
e$B$$$d$9$5$,B-$j$^$;$s$h$M!#e(B