]> git.openfabrics.org - ~shefty/librdmacm.git/commit
[librdmacm,8/8] Open files with "close on exec" flag
authorYann Droneaud <ydroneaud@opteya.com>
Tue, 16 Jul 2013 21:59:52 +0000 (23:59 +0200)
committerSean Hefty <sean.hefty@intel.com>
Tue, 16 Jul 2013 23:07:21 +0000 (16:07 -0700)
commitcf9fc3a4934d30a85d5ca8962007ed50dfc73fcd
tree339f42f99074732d6646a2c98d4674ae2e4b0df3
parent1749a1054a0e36e4b0f77b5c9add8dee907a8ebf
[librdmacm,8/8] Open files with "close on exec" flag

File opened by librdmacm are not supposed to be inherited across
exec*(), most of the files are of no use for another program, and
others cannot be used without the associated memory mapping.

This patch changes fopen() open() and socket() to always set
close on exec flag.

This patch also add checks to configure to guess if fopen() supports
"e" flag. If O_CLOEXEC and SOCK_CLOEXEC are supported, fopen() should
support "e". If not supported, its discarded according to POSIX. Many
operating systems have support for fopen("e").

You might find more information about close on exec in the following articles:

- "Excuse me son, but your code is leaking !!!" by Dan Walsh
  http://danwalsh.livejournal.com/53603.html

- "Secure File Descriptor Handling" by Ulrich Drepper
  http://udrepper.livejournal.com/20407.html

Note: this patch won't set close on exec flag on file descriptors
created by the kernel for completion channel and such.
This is addressed by another kernel patch.

Signed-off-by: Yann Droneaud <ydroneaud@opteya.com>
Signed-off-by: Sean Hefty <sean.hefty@intel.com>
configure.ac
src/acm.c
src/cma.c