# IO#reopen bug in 1.8.4?

**URL:** <https://www.ruby-forum.com/t/io-reopen-bug-in-1-8-4/102059>\
**Category:** Ruby\
**Created:** [February 7, 2006, 5:39pm UTC](https://www.ruby-forum.com/t/io-reopen-bug-in-1-8-4/102059 "2006-02-07T17:39:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![inari](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/838e76/32.png) [@inari](https://www.ruby-forum.com/u/inari)\
**Post date:** [February 7, 2006, 5:39pm UTC](https://www.ruby-forum.com/t/io-reopen-bug-in-1-8-4/102059/1 "2006-02-07T17:39:14Z")

</div>

Greetings list,

$stdout.fileno =\> 1  
$stderr.fileno =\> 2  
$stderr.reopen($stdout)  
$stderr.fileno =\> 2

Shouldn’t that last line evaluate to 1?

BTW, it does indeed redirect STDERR to STDOUT, it’s just that the  
#fileno  
appears to be wrong.

---

<div class="post-metadata">

**Author:** ![inari](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/838e76/32.png) [@inari](https://www.ruby-forum.com/u/inari)\
**Post date:** [February 7, 2006, 5:57pm UTC](https://www.ruby-forum.com/t/io-reopen-bug-in-1-8-4/102059/2 "2006-02-07T17:57:56Z")

</div>

On Wed, 8 Feb 2006, Jason C. wrote:

> appears to be wrong.  
> i think it’s ok

```
 harp:~ > strace ruby -e' STDERR.reopen STDOUT ' 2>&1| tail
 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
 geteuid32() = 447
 getegid32() = 447
 getuid32() = 447
 geteuid32() = 447
 getgid32() = 447
 getegid32() = 447
 dup2(1, 2) = 2
 rt_sigaction(SIGINT, {SIG_DFL}, {0x80a1ff4, [], 

```

SA\_RESTORER|SA\_RESTART, 0x3710d8}, 8) = 0  
exit\_group(0) = ?

so all that’s happening is a dup2. in that case there should in fact be  
two  
fds (fileno).

regards.

-a
