os: wrap socket(SOCK_CLOEXEC) calls
authorPekka Paalanen <ppaalanen@gmail.com>
Wed, 21 Mar 2012 09:11:26 +0000 (11:11 +0200)
committerPekka Paalanen <ppaalanen@gmail.com>
Fri, 20 Apr 2012 13:26:37 +0000 (16:26 +0300)
commit7134a439c1a028cad51a5160f56c84a961be9f72
tree0d9ec2a744e6b68035db9a37ceea3566b62baa96
parentda6b1a8e4774234c2dbdd9f2875de21b41086d00
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>
src/Makefile.am
src/wayland-client.c
src/wayland-os.c [new file with mode: 0644]
src/wayland-os.h [new file with mode: 0644]
src/wayland-server.c
tests/Makefile.am
tests/os-wrappers-test.c [new file with mode: 0644]