Ruby - IO#ioctl在1.9.3中抛出范围错误,但在32位时不抛出1.9.1

时间:2012-03-07 18:27:44

标签: ruby io 32bit-64bit

ruby-1.9.1-p243 :008 > a,b = IO.pipe
=> [#<IO:0x2010670>, #<IO:0x2010654>] 
ruby-1.9.1-p243 :009 > a.ioctl(0x80000000, "\x00\x00")
    Errno::ENOTTY: Inappropriate ioctl for device
    from (irb):9:in `ioctl'
    from (irb):9
    from /Users/dlampa/.rvm/rubies/ruby-1.9.1-p243/bin/irb:16:in `<main>'

如果IO对象是合适的设备并且命令有效,这将起作用。

ruby-1.9.3-p0 :022 > a,b = IO.pipe
=> [#<IO:fd 9>, #<IO:fd 10>] 
ruby-1.9.3-p0 :023 > a.ioctl(0x80000000, "\x00\x00")
RangeError: bignum too big to convert into `long'
    from (irb):23:in `ioctl'
    from (irb):23
    from /Users/dlampa/.rvm/rubies/ruby-1.9.3-p0/bin/irb:16:in `<main>'

在MacOSX 10.6.8上

我假设这与位签名(可能)有关,并且已经打包和解压缩的内容为有符号和无符号,但似乎没有任何东西阻止1.9.3抛出该范围错误。当然,在64位实现中没有问题。我完全糊涂了。有人可以解释为什么会发生这种情况并提供解决方法吗?

编辑: 该命令也适用于1.9.2-p290,所以肯定有从1.9.2到1.9.3的变化

ruby-1.9.2-p290 :001 > a,b = IO.pipe
 => [#<IO:fd 3>, #<IO:fd 4>] 
ruby-1.9.2-p290 :002 > a.ioctl(0x80000000, "\x00\x00")
Errno::ENOTTY: Inappropriate ioctl for device
    from (irb):2:in `ioctl'
    from (irb):2
    from /Users/dlampa/.rvm/rubies/ruby-1.9.2-p290/bin/irb:16:in `<main>'

0 个答案:

没有答案