Blame gl/cloexec.h

Packit Service 4684c1
/* cloexec.c - set or clear the close-on-exec descriptor flag
Packit Service 4684c1
Packit Service 4684c1
   Copyright (C) 2004, 2009-2020 Free Software Foundation, Inc.
Packit Service 4684c1
Packit Service 4684c1
   This program is free software: you can redistribute it and/or modify
Packit Service 4684c1
   it under the terms of the GNU Lesser General Public License as published by
Packit Service 4684c1
   the Free Software Foundation; either version 2.1 of the License, or
Packit Service 4684c1
   (at your option) any later version.
Packit Service 4684c1
Packit Service 4684c1
   This program is distributed in the hope that it will be useful,
Packit Service 4684c1
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 4684c1
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service 4684c1
   GNU Lesser General Public License for more details.
Packit Service 4684c1
Packit Service 4684c1
   You should have received a copy of the GNU Lesser General Public License
Packit Service 4684c1
   along with this program.  If not, see <https://www.gnu.org/licenses/>.
Packit Service 4684c1
Packit Service 4684c1
*/
Packit Service 4684c1
Packit Service 4684c1
#include <stdbool.h>
Packit Service 4684c1
Packit Service 4684c1
/* Set the 'FD_CLOEXEC' flag of DESC if VALUE is true,
Packit Service 4684c1
   or clear the flag if VALUE is false.
Packit Service 4684c1
   Return 0 on success, or -1 on error with 'errno' set.
Packit Service 4684c1
Packit Service 4684c1
   Note that on MingW, this function does NOT protect DESC from being
Packit Service 4684c1
   inherited into spawned children.  Instead, either use dup_cloexec
Packit Service 4684c1
   followed by closing the original DESC, or use interfaces such as
Packit Service 4684c1
   open or pipe2 that accept flags like O_CLOEXEC to create DESC
Packit Service 4684c1
   non-inheritable in the first place.  */
Packit Service 4684c1
Packit Service 4684c1
int set_cloexec_flag (int desc, bool value);
Packit Service 4684c1
Packit Service 4684c1
/* Duplicates a file handle FD, while marking the copy to be closed
Packit Service 4684c1
   prior to exec or spawn.  Returns -1 and sets errno if FD could not
Packit Service 4684c1
   be duplicated.  */
Packit Service 4684c1
Packit Service 4684c1
int dup_cloexec (int fd);