summaryrefslogtreecommitdiff
path: root/lib/chef/run_lock.rb
diff options
context:
space:
mode:
authorLamont Granquist <lamont@opscode.com>2013-06-14 14:43:36 -0700
committerLamont Granquist <lamont@opscode.com>2013-06-14 14:43:36 -0700
commitc30083f59dd2860eebd7ca269f1e36837d6a58e6 (patch)
tree0361fd63494f38172da623aef4cb116823068bdd /lib/chef/run_lock.rb
parent9a95a632921001d971365382414ca0c44aca27e4 (diff)
downloadchef-c30083f59dd2860eebd7ca269f1e36837d6a58e6.tar.gz
use F_CLOEXEC if we can
Diffstat (limited to 'lib/chef/run_lock.rb')
-rw-r--r--lib/chef/run_lock.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/chef/run_lock.rb b/lib/chef/run_lock.rb
index c63895e87b..50371d93a1 100644
--- a/lib/chef/run_lock.rb
+++ b/lib/chef/run_lock.rb
@@ -16,6 +16,7 @@
# limitations under the License.
require 'chef/mixin/create_path'
+require 'fcntl'
class Chef
@@ -55,6 +56,10 @@ class Chef
# ensure the runlock_file path exists
create_path(File.dirname(runlock_file))
@runlock = File.open(runlock_file,'w+')
+ # if we support FD_CLOEXEC (linux, !windows), then use it.
+ if Fcntl.const_defined?('F_SETFD') && Fcntl.const_defined?('FD_CLOEXEC')
+ @runlock.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
+ end
unless runlock.flock(File::LOCK_EX|File::LOCK_NB)
# Another chef client running...
runpid = runlock.read.strip.chomp