]> git.ipfire.org Git - thirdparty/coreutils.git/commit
sort: use the more efficient posix_spawn to invoke --compress-program
authorCollin Funk <collin.funk1@gmail.com>
Fri, 24 Oct 2025 04:27:53 +0000 (21:27 -0700)
committerCollin Funk <collin.funk1@gmail.com>
Sat, 25 Oct 2025 19:59:08 +0000 (12:59 -0700)
commit2b3eb795c85633a4b808df44d19a4a9be5976c10
tree535d3652f01ccb3f7b1c0834bf45acbd3f9b9e3f
parenta2a2f22efe12c3394e1f19e0104c67988b2044c8
sort: use the more efficient posix_spawn to invoke --compress-program

* NEWS: Mention the improvement. Mention that 'sort' will continue
without compressing temporary files if the program specified by
--compress-program cannot be executed.
* doc/coreutils.texi (sort invocation): Document the behavior when the
program specified by --compress-program cannot be executed.
* src/sort.c: Include spawn.h.
(MAX_FORK_TRIES_COMPRESS, MAX_FORK_TRIES_DECOMPRESS): Remove definition.
(MAX_TRIES_COMPRESS, MAX_TRIES_DECOMPRESS): New definitions based on
MAX_FORK_TRIES_COMPRESS and MAX_FORK_TRIES_DECOMPRESS.
(async_safe_die): Remove function.
(posix_spawn_file_actions_move_fd): New function.
(pipe_fork): Remove function.
(pipe_child): New function based on pipe_fork. Return an error number
instead of a pid. Use posix_spawnp instead of calling fork and expecting
the caller to exec.
(maybe_create_temp): Call pipe_child instead of pipe_fork. Print a
warning to standard error if --compress-program cannot be executed and
the error is different than the previous call. Remove code for the child
process.
(open_temp): Remove code for the child process. Improve error message.
* tests/sort/sort-compress.sh: Add a test case for when the program
specified by --compress-program does not exist.
NEWS
doc/coreutils.texi
src/sort.c
tests/sort/sort-compress.sh