Professional Web Applications Themes

`close': Bad file descriptor - filename (Errno::EBADF) - Ruby

While upgrading rubicon from 1.6 to 1.8, I bumped into this problem in the builtin/TestIO.rb file. http://rubyforge.org/cgi-bin/viewcvs/cgi/viewcvs.cgi/rubicon/builtin/TestIO.rb?cvsroot=rubytests I have extracted the code which reproduces the problem. Any ideas on how to solve it, would be nice. server> rm testtest server> ruby a.rb a.rb:5:in `close': Bad file descriptor - testtest (Errno::EBADF) from a.rb:5:in `open' from a.rb:5 server> expand -t2 a.rb file = "testtest" File.open(file, "w") do |f| 10.times { |i| f.printf "%02d: This is a line\n", i } end File.open(file, "w") do |f| io = IO.new(f.fileno, "w") io << 1 << "\n" << "dummy" << "\n" << "cat\n" io.close end server> ...

  1. #1

    Default `close': Bad file descriptor - filename (Errno::EBADF)

    While upgrading rubicon from 1.6 to 1.8, I bumped into
    this problem in the builtin/TestIO.rb file.
    http://rubyforge.org/cgi-bin/viewcvs/cgi/viewcvs.cgi/rubicon/builtin/TestIO.rb?cvsroot=rubytests


    I have extracted the code which reproduces the problem.
    Any ideas on how to solve it, would be nice.


    server> rm testtest
    server> ruby a.rb
    a.rb:5:in `close': Bad file descriptor - testtest (Errno::EBADF)
    from a.rb:5:in `open'
    from a.rb:5
    server> expand -t2 a.rb
    file = "testtest"
    File.open(file, "w") do |f|
    10.times { |i| f.printf "%02d: This is a line\n", i }
    end
    File.open(file, "w") do |f|
    io = IO.new(f.fileno, "w")
    io << 1 << "\n" << "dummy" << "\n" << "cat\n"
    io.close
    end
    server>

    --
    Simon Strandgaard
    Simon Guest

  2. #2

    Default Re: `close': Bad file descriptor - filename (Errno::EBADF)

    Hi,

    In message "`close': Bad file descriptor - filename (Errno::EBADF)"
    on 04/02/16, Simon Strandgaard <dk> writes:

    |While upgrading rubicon from 1.6 to 1.8, I bumped into
    |this problem in the builtin/TestIO.rb file.
    |http://rubyforge.org/cgi-bin/viewcvs/cgi/viewcvs.cgi/rubicon/builtin/TestIO.rb?cvsroot=rubytests

    It's a bug in rubicon. Try test suites bundled with 1.8.1 or later.

    |File.open(file, "w") do |f|
    | io = IO.new(f.fileno, "w")
    | io << 1 << "\n" << "dummy" << "\n" << "cat\n"
    | io.close <= close io here.
    |end <= open close io at the end of block (i.e. double close)

    matz.


    Yukihiro Guest

  3. #3

    Default Re: `close': Bad file descriptor - filename (Errno::EBADF)

    On Mon, 16 Feb 2004 22:51:36 +0900, Yukihiro Matsumoto wrote: 
    [snip code] 

    Chad Fowler and I are working on upgrading rubicon for ruby-1.8.1.
    We have made a transition from rubyunit to now use testunit.

    I am working with the CVS version (I don't think there is a newer rubicon
    suite?) ;-)

    You can see the pending bugs here:
    http://rubyforge.org/tracker/?func=browse&group_id=179&atid=751
    Please comment on these :-)


    The code which I am looking at is

    def test_LSHIFT # '<<'
    File.open(file, "w") do |file|
    io = IO.new(file.fileno, "w")
    io << 1 << "\n" << Dummy.new << "\n" << "cat\n"
    io.close
    end
    expected = [ "1\n", "dummy\n", "cat\n"]
    IO.foreach(file) do |line|
    assert_equal(expected.shift, line)
    end
    assert_equal([], expected)
    end

    Why make an instance of the IO class, when its the '<<' leftshift
    operator we want to test?

    --
    Simon Strandgaard
    Simon Guest

  4. #4

    Default Re: `close': Bad file descriptor - filename (Errno::EBADF)

    On Mon, 16 Feb 2004 17:02:50 +0100, Simon Strandgaard wrote:
     

    Ok I have one last problem with Bad File Descriptor.
    The source code for TestIO.rb is here:
    http://rubyforge.org/cgi-bin/viewcvs/cgi/viewcvs.cgi/rubicon/builtin/TestIO.rb?cvsroot=rubytests


    server> ruby TestIO.rb
    Loaded suite TestIO
    Started
    ..S.....E....S......S............................. .......
    Finished in 0.833549 seconds.

    1) Error:
    test_closed?(TestIO):
    Errno::EBADF: Bad file descriptor - _test/_99lines
    TestIO.rb:19:in `close'
    TestIO.rb:19:in `open'
    TestIO.rb:19:in `setup'

    53 tests, 1242 assertions, 0 failures, 1 errors
    server>

    --
    Simon Strandgaard
    Simon Guest

  5. #5

    Default Re: `close': Bad file descriptor - filename (Errno::EBADF)

    On Mon, 16 Feb 2004 18:09:08 +0100, Simon Strandgaard wrote: 
    [snip]

    Solved.. It was a typo I had made, writing 'clone' where I meant 'close'.


    Sorry for the noise.

    --
    Simon Strandgaard

    Simon Guest

Similar Threads

  1. Air extension could not create app descriptor file
    By johntmcii in forum Macromedia Exchange Dreamweaver Extensions
    Replies: 3
    Last Post: October 22nd, 10:17 PM
  2. #40214 [NEW]: Bad File Descriptor, Please help me
    By support at vikoshosting dot com in forum PHP Bugs
    Replies: 1
    Last Post: January 24th, 09:28 AM
  3. Dup 2: Bad File Descriptor...Whuzzat mean?
    By Michael in forum Linux Setup, Configuration & Administration
    Replies: 4
    Last Post: September 25th, 03:25 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139