Back to index

nagios-plugins  1.4.16
cloexec.h
Go to the documentation of this file.
00001 /* closexec.c - set or clear the close-on-exec descriptor flag
00002 
00003    Copyright (C) 2004, 2009-2010 Free Software Foundation, Inc.
00004 
00005    This program is free software: you can redistribute it and/or modify
00006    it under the terms of the GNU General Public License as published by
00007    the Free Software Foundation; either version 3 of the License, or
00008    (at your option) any later version.
00009 
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013    GNU General Public License for more details.
00014 
00015    You should have received a copy of the GNU General Public License
00016    along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017 
00018 */
00019 
00020 #include <stdbool.h>
00021 
00022 /* Set the `FD_CLOEXEC' flag of DESC if VALUE is true,
00023    or clear the flag if VALUE is false.
00024    Return 0 on success, or -1 on error with `errno' set.
00025 
00026    Note that on MingW, this function does NOT protect DESC from being
00027    inherited into spawned children.  Instead, either use dup_cloexec
00028    followed by closing the original DESC, or use interfaces such as
00029    open or pipe2 that accept flags like O_CLOEXEC to create DESC
00030    non-inheritable in the first place.  */
00031 
00032 int set_cloexec_flag (int desc, bool value);
00033 
00034 /* Duplicates a file handle FD, while marking the copy to be closed
00035    prior to exec or spawn.  Returns -1 and sets errno if FD could not
00036    be duplicated.  */
00037 
00038 int dup_cloexec (int fd);