diff options
author | Jesse Wolfe <jes5199@gmail.com> | 2010-10-04 20:11:56 -0700 |
---|---|---|
committer | Jesse Wolfe <jes5199@gmail.com> | 2010-10-04 21:46:59 -0700 |
commit | 7bdbd132634f61d91aeee401de15248d936ce71e (patch) | |
tree | 146bb43d90478d373f9bb1c5ed3e04bd9d04dbbc /lib/puppet/external | |
parent | 163ec172e06a2b8aab9f9c9247dd45bc0dea3f72 (diff) | |
parent | 917c520f1abc0c72d7065531cffcef88259e32e0 (diff) | |
download | puppet-7bdbd132634f61d91aeee401de15248d936ce71e.tar.gz puppet-7bdbd132634f61d91aeee401de15248d936ce71e.tar.xz puppet-7bdbd132634f61d91aeee401de15248d936ce71e.zip |
Merge commit '2.6.2rc1' into next
Diffstat (limited to 'lib/puppet/external')
-rw-r--r-- | lib/puppet/external/event-loop/event-loop.rb | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/lib/puppet/external/event-loop/event-loop.rb b/lib/puppet/external/event-loop/event-loop.rb index dc51a55ae..3b40f6e71 100644 --- a/lib/puppet/external/event-loop/event-loop.rb +++ b/lib/puppet/external/event-loop/event-loop.rb @@ -75,8 +75,10 @@ class EventLoop @notify_src, @notify_snk = IO.pipe # prevent file descriptor leaks - @notify_src.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) - @notify_snk.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) + if @notify_src.respond_to?(:fcntl) and defined?(Fcntl) and defined?(Fcntl::F_SETFD) and defined?(Fcntl::FD_CLOEXEC) + @notify_src.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) + @notify_snk.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) + end @notify_src.will_block = false @notify_snk.will_block = false @@ -234,19 +236,21 @@ class IO end def will_block? - require "fcntl" - fcntl(Fcntl::F_GETFL, 0) & Fcntl::O_NONBLOCK == 0 + if respond_to?(:fcntl) and defined?(Fcntl) and defined?(Fcntl::F_GETFL) and defined?(Fcntl::O_NONBLOCK) + fcntl(Fcntl::F_GETFL, 0) & Fcntl::O_NONBLOCK == 0 + end end def will_block= (wants_blocking) - require "fcntl" - flags = fcntl(Fcntl::F_GETFL, 0) - if wants_blocking - flags &= ~Fcntl::O_NONBLOCK - else - flags |= Fcntl::O_NONBLOCK + if respond_to?(:fcntl) and defined?(Fcntl) and defined?(Fcntl::F_GETFL) and defined?(Fcntl::O_NONBLOCK) + flags = fcntl(Fcntl::F_GETFL, 0) + if wants_blocking + flags &= ~Fcntl::O_NONBLOCK + else + flags |= Fcntl::O_NONBLOCK + end + fcntl(Fcntl::F_SETFL, flags) end - fcntl(Fcntl::F_SETFL, flags) end end |