X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=util%2Fpidfile.cc;h=c6c5b4401b64698c0b24e0269811b343cffff23c;hb=12911320d89ae182f96305d11830f6168bcdd8e6;hp=11f7f398d7962d3cb02495f3a743fae3a552e094;hpb=087e642e50a895d2e700dec7afe1d089dd9d703f;p=awesomized%2Flibmemcached diff --git a/util/pidfile.cc b/util/pidfile.cc index 11f7f398..c6c5b440 100644 --- a/util/pidfile.cc +++ b/util/pidfile.cc @@ -118,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) << ")";