commit: 77d53cebb34b78d3d3647a8812993330491af31f
Author: Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Sat Jun 7 20:28:47 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Jun 7 22:54:16 2025 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=77d53ceb
ecompress: refrain from calling die() inside process substitutions
I care not for the approach of invoking the die() function from inside a
process substitution. Given that they are asynchronous in nature, one
ought to be mindful of the prospect of a race condition occurring.
Instead, have the parent shell wait for process substitutions to
conclude before collecting their exit status values and choosing whether
to call die(). To accomplish this, the wait builtin is invoked in a
manner that is acceptable as of bash >=4.4.
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>
bin/ecompress | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/bin/ecompress b/bin/ecompress
index b6063d87ce..c56c51774c 100755
--- a/bin/ecompress
+++ b/bin/ecompress
@@ -31,8 +31,11 @@ do_ignore() {
skip=${skip%.ecompress}
printf '%s\n' "${skip#"${D%/}"}" || ! break
done \
- < <(printf '%s\0' "${skip_dirs[@]}" | find0 -name '*.ecompress'
-print0 -delete || die) \
+ < <(printf '%s\0' "${skip_dirs[@]}" | find0 -name '*.ecompress'
-print0 -delete) \
>> "${T}/.ecompress_skip_files" || die
+
+ # Check whether the invocation of find(1) succeeded.
+ wait "$!" || die
fi
if [[ -s ${T}/.ecompress_skip_files && -s
${T}/.ecompress_had_precompressed ]]; then
@@ -86,9 +89,12 @@ do_queue() {
: >> "${path}.ecompress" || die
done \
- < <(printf '%s\0' "${paths[@]}" | find0 "${find_args[@]}"
-print0 || die) \
+ < <(printf '%s\0' "${paths[@]}" | find0 "${find_args[@]}"
-print0) \
> "${T}"/.ecompress_had_precompressed || die
+ # Check whether the invocation of find(1) succeeded.
+ wait "$!" || die
+
if (( ${#collisions[@]} )); then
eqawarn "QA Notice: Colliding files found by ecompress:"
eqawarn