Re: Bad file descriptor error



On 12.04.2009 04:58, Roger Pack wrote:
Errno::EBADF: Bad file descriptor
from C:/Ruby/lib/ruby/1.8/net/http.rb:564:in `write'
from C:/Ruby/lib/ruby/1.8/net/http.rb:564:in `warn'
from C:/Ruby/lib/ruby/1.8/net/http.rb:564:in `connect'
from C:/Ruby/lib/ruby/1.8/net/http.rb:553:in `do_start'
from C:/Ruby/lib/ruby/1.8/net/http.rb:542:in `start'
from C:/Ruby/lib/ruby/1.8/net/http.rb:1035:in `request'
from C:/Ruby/lib/ruby/1.8/net/http.rb:845:in `post'
from (irb):15:in `authentication'
from (irb):23
from :0
irb(main):024:0>

It may mean that google has summarily hung up on you.

I believe you would see a different error. EBADF occurs, if the file descriptor (i.e. the numeric value) is invalid. You can provoke it by doing something like this

ruby -e 'File.open(10, "w") {|f| f.puts "test"}'

Whereas it does not happen if you do

ruby -e 'File.open(1, "w") {|f| f.puts "test"}'

One way to create this is to open a file, remember the number returned from #fileno, close the file and then open another file with the remembered number (file descriptor).

Kind regards

robert
.



Relevant Pages

  • Re: Solaris 10 - catman weird error
    ... DTrace can absolutely help in this situation. ... returns EIO or EBADF: ... probably want to know _how_ exactly the file descriptor was closed. ... that you know the process ID of the problematic process, here is a D script ...
    (comp.unix.solaris)
  • Possible error in Beejs guide to IPC document
    ... My query is for Unix IPC. ... I think he meant to say fcntl() will return EBADF. ... accept the path and returns a file descriptor which we input to fcntl ...
    (comp.unix.programmer)
  • Re: close() on a closed file descriptor in Visual Studio 8
    ... returns EBADF and everybody goes on with their lives. ... In Visual Studio ... just goes through the file descriptor table and closes them all (pretty ... as described in Parameter Validation. ...
    (microsoft.public.vc.language)
  • Re: Problem with socketpair , AF_UNIX and select call - can anybody through any light on this!
    ... might succeed, not a guarantee (google for "spurious wakeup"), hence a ... subsequent read/write might block if the descriptor isn't set to ... selectmay report a socket file descriptor ...
    (Fedora)
  • Re: [RFC/PATCH] revoke/frevoke system calls V2
    ... As a bonus, ... it works for regular files and even goes as far as destroying ... "EBADF" is not something that applications are taught to expect. ... Someone correct me if I'm wrong, but I can think of no situation under which a file descriptor currently gets yanked out from under your feet -- you should always have to formally abandon it with close. ...
    (Linux-Kernel)