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>
This commit is contained in:
Pekka Paalanen 2012-03-21 11:11:26 +02:00
parent da6b1a8e47
commit 7134a439c1
7 changed files with 211 additions and 3 deletions

View file

@ -5,7 +5,8 @@ my_check_programs = \
list-test \
connection-test \
event-loop-test \
client-test
client-test \
os-wrappers-test
TESTS = $(my_check_programs)
@ -23,6 +24,11 @@ connection_test_SOURCES = connection-test.c $(test_runner_src)
event_loop_test_SOURCES = event-loop-test.c $(test_runner_src)
client_test_SOURCES = client-test.c $(test_runner_src)
os_wrappers_test_SOURCES = \
os-wrappers-test.c \
../src/wayland-os.c \
$(test_runner_src)
AM_CFLAGS = $(GCC_CFLAGS)
LDADD = $(top_builddir)/src/libwayland-util.la \
$(top_builddir)/src/libwayland-server.la \