Project

General

Profile

Actions

Backport #5664

closed

Webrick broken FD_CLOEXEC

Added by candlerb (Brian Candler) over 12 years ago. Updated over 7 years ago.


Description

ruby-1.8.7-p352 $ grep -R CLOEXEC .
./ext/fcntl/fcntl.c: * - FD_CLOEXEC - the value of the close-on-exec flag.
./ext/fcntl/fcntl.c:#ifdef FD_CLOEXEC
./ext/fcntl/fcntl.c: rb_define_const(mFcntl, "FD_CLOEXEC", INT2NUM(FD_CLOEXEC));
./lib/drb/drb.rb: soc.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) if defined? Fcntl::FD_CLOEXEC
./lib/drb/unix.rb: soc.fcntl(Fcntl::F_SETFL, Fcntl::FD_CLOEXEC) if defined? Fcntl::FD_CLOEXEC
./lib/resolv.rb: sock.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) if defined? Fcntl::F_SETFD
./lib/resolv.rb: sock.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) if defined? Fcntl::F_SETFD
./lib/resolv.rb: sock.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) if defined? Fcntl::F_SETFD
./lib/webrick/utils.rb: if defined?(Fcntl::FD_CLOEXEC)
./lib/webrick/utils.rb: io.fcntl(Fcntl::FD_CLOEXEC, 1)

There you can see lots of examples of FD_CLOEXEC being used correctly: fcntl (command F_SETFD, value FD_CLOEXEC)

But in the last line, Webrick is calling fcntl wrongly: it is calling command FD_CLOEXEC with value 1 !! So what it's actually calling is command F_GETFD, which does nothing.

Fcntl.constants.select { |x| Fcntl.const_get(x) == Fcntl::FD_CLOEXEC }
=> ["F_GETFD", "FD_CLOEXEC", "O_WRONLY", "F_RDLCK"]

I have checked this in the latest 1.8.7-p352 source too, and it's the same there.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0