On 26/10/2025 22:33, Collin Funk wrote:
* NEWS: Mention the improvement.
* bootstrap.conf (gnulib_modules): Add posix_spawnattr_setsigmask.
* src/timeout.c: Include spawn.h.
(main): Setup signals using a posix_spawnattr_t object. Use posix_spawn
instead of fork and execvp.
---
NEWS | 3 +++
bootstrap.conf | 1 +
src/timeout.c | 42 ++++++++++++++++++++++++------------------
3 files changed, 28 insertions(+), 18 deletions(-)
There is negligible perf gain from this one,
but since it's the only fork() left in coreutils
it probably makes sense to use posix_spawn() everywhere.
I verified the syscalls are the same before and after,
well apart from the clone adjustments which changed as follows:
-clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD,
...
+mmap(NULL, 36864, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK,
-1, 0)
+clone3({flags=CLONE_VM|CLONE_VFORK|CLONE_CLEAR_SIGHAND, exit_signal=SIGCHLD,
stack=...
+munmap(0x7fc2db6a5000, 36864)
The patch looks good.
I would consolidate the NEWS to one item along the lines of:
install, sort, split, and timeout now use posix_spawn() to invoke child
programs
more efficiently and more independently from their own memory usage.
thanks!
Padraig