[Patch, libgfortran] Set close-on-exec flag when opening files
Janne Blomqvist
blomqvist.janne@gmail.com
Tue Oct 29 23:39:00 GMT 2013
Hello,
the attached patch sets the close-on-exec flag when opening files, as
is usually considered good practice these days. See e.g.
http://www.python.org/dev/peps/pep-0446/ and links therein for more
information.
The preconnected units INPUT_UNIT, OUTPUT_UNIT, ERROR_UNIT are not
affected, only new units created with the OPEN statement. In the
(very!?) unlikely event that someone really needs Fortran units to be
inherited to child processes, the close-on-exec flag can be cleared
with fcntl() before calling one of the exec() family functions.
Regtested on x86_64-unknown-linux-gnu, Ok for trunk?
2013-10-30 Janne Blomqvist <jb@gcc.gnu.org>
* configure.ac: Check presence of mkostemp.
* io/unix.c (set_close_on_exec): New function.
(tempfile_open): Use mkostemp and O_CLOEXEC if available, fallback
to calling set_close_on_exec.
(regular_file): Add O_CLOEXEC to flags if defined.
(open_external): Call set_close_on_exec if O_CLOEXEC is not
defined.
* config.h.in: Regenerated.
* configure: Regenerated.
--
Janne Blomqvist
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cloexec.diff
Type: text/x-patch
Size: 3214 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20131029/7adf125c/attachment.bin>
More information about the Fortran
mailing list