]> git.sesse.net Git - vlc/commit
Linux: create sockets with close-on-exec flag in thread-safe manner
authorRémi Denis-Courmont <remi@remlab.net>
Sun, 8 Nov 2009 10:38:41 +0000 (12:38 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Sun, 8 Nov 2009 10:38:41 +0000 (12:38 +0200)
commit303fbc7c9c9246918eebeb4cbcd04a9b5e50f90f
tree37f09c665ba7b35ca7138905642251cf9b6897ea
parentaca7ce705bca23a36afd44091841cbd70b404e02
Linux: create sockets with close-on-exec flag in thread-safe manner

There is a window of opportunity to leak file descriptors between
their creation and the fcntl(FD_CLOEXEC) call. If another thread forks
during this window, the descriptors will not have a the close-on-exec
flag, and get leaked after exec(). This is a limitation of POSIX.

While we're using the Linux-specific SOCK_CLOEXEC, we might as well
use SOCK_NONBLOCK, and spare ourselves the three fcntl() calls.
src/network/io.c