diff options
author | Pekka Paalanen <ppaalanen@gmail.com> | 2012-03-21 11:11:26 +0200 |
---|---|---|
committer | Pekka Paalanen <ppaalanen@gmail.com> | 2012-04-20 16:26:37 +0300 |
commit | 7134a439c1a028cad51a5160f56c84a961be9f72 (patch) | |
tree | 0d9ec2a744e6b68035db9a37ceea3566b62baa96 /src/wayland-os.h | |
parent | da6b1a8e4774234c2dbdd9f2875de21b41086d00 (diff) |
os: wrap socket(SOCK_CLOEXEC) calls
Some system C libraries do not offer SOCK_CLOEXEC flag.
Add a new header for OS compatibility wrappers. Wrap socket() calls into
wl_os_socket_cloexec() which makes sure the O_CLOEXEC flag gets set on
the file descriptor.
On systems having SOCK_CLOEXEC this uses the old socket() call, and
falls back if it fails due to the flag (kernel not supporting it).
wayland-os.h is private and not exported.
Add close-on-exec tests for both normal and forced fallback paths.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Diffstat (limited to 'src/wayland-os.h')
-rw-r--r-- | src/wayland-os.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/wayland-os.h b/src/wayland-os.h new file mode 100644 index 0000000..49adc2b --- /dev/null +++ b/src/wayland-os.h @@ -0,0 +1,29 @@ +/* + * Copyright © 2012 Collabora, Ltd. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifndef WAYLAND_OS_H +#define WAYLAND_OS_H + +int +wl_os_socket_cloexec(int domain, int type, int protocol); + +#endif |