]> git.openfabrics.org - ~shefty/librdmacm.git/commit
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>
Wed, 17 Jul 2013 04:20:06 +0000 (21:20 -0700)
commit3eb1704b2e11413077933d6d3a963d81d508bdf8
treee14708a457c3eac12d51c437d6b9f6fac401ea73
parentd53cd79c3bde6186bda6822a04708b9d2666f8ae
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