X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;ds=sidebyside;f=util%2Fpidfile.cc;h=90a6d17818096a77a72ddf4a98b68e9130f3409a;hb=1d0993d84fd87ef620f60380745914bac3e77d34;hp=c44b90817023101fd88e45adca25f2bc99a7d75b;hpb=5d66b2f99bf7de6f54a3e463b01542b997f68ac8;p=awesomized%2Flibmemcached diff --git a/util/pidfile.cc b/util/pidfile.cc index c44b9081..90a6d178 100644 --- a/util/pidfile.cc +++ b/util/pidfile.cc @@ -35,7 +35,7 @@ * */ -#include "config.h" +#include "mem_config.h" #include "util/pidfile.hpp" @@ -48,6 +48,7 @@ #include #include #include +#include extern "C" { @@ -117,8 +118,13 @@ bool Pidfile::create() } } + int oflags= O_CREAT|O_WRONLY|O_TRUNC; +#ifdef HAVE_O_CLOEXEC + oflags= oflags | O_CLOEXEC; +#endif + int file; - if ((file = open(_filename.c_str(), O_CREAT|O_WRONLY|O_TRUNC, S_IRWXU|S_IRGRP|S_IROTH)) < 0) + if ((file = open(_filename.c_str(), oflags, S_IRWXU|S_IRGRP|S_IROTH)) < 0) { std::stringstream error_stream; error_stream << "Could not open pid file for writing: " << _filename << "(" << strerror(errno) << ")";