1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2011 New Dream Network
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
14 #include "include/compat.h"
20 int pipe_cloexec(int pipefd[2])
24 #if defined(HAVE_PIPE2) && defined(O_CLOEXEC)
25 ret = pipe2(pipefd, O_CLOEXEC);
35 * The old-fashioned, race-condition prone way that we have to fall
36 * back on if O_CLOEXEC does not exist.
38 ret = fcntl(pipefd[0], F_SETFD, FD_CLOEXEC);
44 ret = fcntl(pipefd[1], F_SETFD, FD_CLOEXEC);
53 VOID_TEMP_FAILURE_RETRY(close(pipefd[0]));
54 VOID_TEMP_FAILURE_RETRY(close(pipefd[1]));