From: matz@... (Yukihiro Matsumoto) Date: 1998-09-17T17:01:31+09:00 Subject: [ruby-list:9593] Re: filter まつもと ゆきひろです In message "[ruby-list:9592] Re: filter" on 98/09/17, GOTO Kentaro writes: |ごとけんです |> STDIN.reopen(pw[0]) |> pw[0].close | |この reopen したあとの pw[0].close って必要なんでしょうか?? reopenは内部でdupしてますので必要です. んで,確認のため今ソースを見たらバグがありました.今回は関係 ありませんけど.パッチです. --- io.c 1998/08/27 03:55:18 1.1.1.2.2.47 +++ io.c 1998/09/17 08:00:28 @@ -1361,5 +1361,6 @@ fd = fileno(fptr->f); - if (fileno(fptr->f) < 3) { + if (fd < 3) { /* need to keep stdio */ - dup2(fileno(orig->f), fd); + if (dup2(fileno(orig->f), fd) < 0) + rb_sys_fail(orig->path); } @@ -1367,2 +1368,4 @@ fclose(fptr->f); + if (dup2(fileno(orig->f), fd) < 0) + rb_sys_fail(orig->path); fptr->f = rb_fdopen(fd, mode); @@ -1374,3 +1377,4 @@ if (orig->f2) { - dup2(fileno(orig->f2), fd); + if (dup2(fileno(orig->f2), fd) < 0) + rb_sys_fail(orig->path); fptr->f2 = rb_fdopen(fd, "w");