]> git.ipfire.org Git - thirdparty/coreutils.git/commit
sort: file descriptor discipline
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 17 Aug 2017 15:03:57 +0000 (08:03 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 17 Aug 2017 19:03:03 +0000 (12:03 -0700)
commit717f1d02e1707b18271a83812989e778c6f5cb77
tree31a9b682db5874ea362546e5ebbe23278589331c
parent72f1751f6075b036e055a39c8abbbddac6c225c7
sort: file descriptor discipline

Use O_CLOEXEC when creating file descriptors, so that subsidiary
processes do not inherit file descriptors that they do not need.
This is helpful for ‘sort’, as it is a multithreaded program that
forks and execs.
* bootstrap.conf (gnulib_modules): Add mkostemp, open, pipe2.
* src/sort.c (create_temp_file): Open temporary file with O_CLOEXEC.
(stream_open): Open the stream with O_CLOEXEC.
(pipe_fork): Create the pipe with O_CLOEXEC.
(check_output): Open the output file with O_CLOEXEC.
(main): Use xfopen/xfclose to handle --files0-from, so that
O_CLOEXEC is used properly.  This is simpler anyway.
* tests/misc/sort-files0-from.pl: Adjust to change in diagnostic
wording.
bootstrap.conf
src/sort.c
tests/misc/sort-files0-from.pl