MPD

- Main Page
- Data Structures
- Files

- File List
- Globals

# src/fd_util.h

Go to the documentation of this file.

    00001 /*
    00002  * Copyright (C) 2003-2010 The Music Player Daemon Project
    00003  * http://www.musicpd.org
    00004  *
    00005  * Redistribution and use in source and binary forms, with or without
    00006  * modification, are permitted provided that the following conditions
    00007  * are met:
    00008  *
    00009  * - Redistributions of source code must retain the above copyright
    00010  * notice, this list of conditions and the following disclaimer.
    00011  *
    00012  * - Redistributions in binary form must reproduce the above copyright
    00013  * notice, this list of conditions and the following disclaimer in the
    00014  * documentation and/or other materials provided with the distribution.
    00015  *
    00016  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    00017  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    00018  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    00019  * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
    00020  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    00021  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    00022  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
    00023  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
    00024  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    00025  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    00026  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    00027  */
    00028
    00029 /*
    00030  * This library provides easy helper functions for working with file
    00031  * descriptors.  It has wrappers for taking advantage of Linux 2.6
    00032  * specific features like O_CLOEXEC.
    00033  *
    00034  */
    00035
    00036 #ifndef FD_UTIL_H
    00037 #define FD_UTIL_H
    00038
    00039 #include <stdbool.h>
    00040 #include <stddef.h>
    00041
    00042 #ifndef WIN32
    00043 #if !defined(_GNU_SOURCE) && (defined(HAVE_PIPE2) || defined(HAVE_ACCEPT4))
    00044 #define _GNU_SOURCE
    00045 #endif
    00046
    00047 #include <sys/types.h>
    00048 #endif
    00049
    00050 struct sockaddr;
    00051
    00056 int
    00057 dup_cloexec(int oldfd);
    00058
    00063 int
    00064 open_cloexec(const char *path_fs, int flags, int mode);
    00065
    00070 int
    00071 pipe_cloexec(int fd[2]);
    00072
    00080 int
    00081 pipe_cloexec_nonblock(int fd[2]);
    00082
    00083 #ifndef WIN32
    00084
    00089 int
    00090 socketpair_cloexec(int domain, int type, int protocol, int sv[2]);
    00091
    00092 #endif
    00093
    00098 int
    00099 socket_cloexec_nonblock(int domain, int type, int protocol);
    00100
    00105 int
    00106 accept_cloexec_nonblock(int fd, struct sockaddr *address,
    00107                         size_t *address_length_r);
    00108
    00109
    00110 #ifndef WIN32
    00111
    00112 struct msghdr;
    00113
    00118 ssize_t
    00119 recvmsg_cloexec(int sockfd, struct msghdr *msg, int flags);
    00120
    00121 #endif
    00122
    00127 int
    00128 inotify_init_cloexec(void);
    00129
    00130 #endif