coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sort: prefer posix_spawnp to fork and execlp


From: Pádraig Brady
Subject: Re: sort: prefer posix_spawnp to fork and execlp
Date: Wed, 29 Oct 2025 00:55:53 +0000
User-agent: Mozilla Thunderbird Beta

On 28/10/2025 17:33, Pádraig Brady wrote:
I've only thought about this for a couple of minutes but the attached could 
work,
where we always ignore SIGPIPE and then convert the EPIPE on stdout to SIGPIPE.

I'll do lots of testing with this and add a new test before pushing,
but it does pass basic tests here:

#  ---- put previous exit statuses in prompt
$ PS1="[\[\033[1;31m\]\${PIPESTATUS[@]/#0/\[\033[0m\]"\
"\[\033[1;32m\]0\[\033[1;31m\]}\[\033[0m\]] \w$"

[0] $ printf '%s\n' '#!/bin/sh' 'exit 1' > exit1 && chmod a+x exit1

# ---- we now diagnose these failures always
[0] $ src/sort -S 100K --compress-program=./exit1 Makefile | head -n1
sort: write failed: /tmp/sortlh70wt: Broken pipe

# ---- normal pipe operation is maintained
[2 0] $ seq 10000 | sort | :
[0 141 0] $

That idea seems to work, but I needed to tweak to
ensure we cleanup() to remove temp files upon receiving the SIGPIPE.

I'll apply attached patch tomorrow.

cheers,
Padraig

Attachment: sort-compress-sigpipe.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]