Without O_CLOEXEC the pipe fds are inherited across any future exec()
calls. While the child in get_early_config does not exec, using
O_CLOEXEC is standard practice to prevent inadvertent fd leaks into
subprocesses spawned later in the OSD lifetime.
Signed-off-by: Kefu Chai <k.chai@proxmox.com>
#include "crimson/mon/MonClient.h"
#include "crimson/net/Messenger.h"
-#include <sys/wait.h> // for waitpid()
+#include <fcntl.h>
+#include <sys/wait.h>
using namespace std::literals;
using crimson::common::local_conf;
exit(0);
}
int pipes[2];
- int r = pipe2(pipes, 0);
+ int r = pipe2(pipes, O_CLOEXEC);
if (r < 0) {
std::cerr << "get_early_config: failed to create pipes: "
<< -errno << std::endl;