Collin Funk <[email protected]> writes:

> Bruno Haible via GNU coreutils General Discussion <[email protected]>
> writes:
>
>> + LC_ALL=C diff -u exp out
>> + mkdir -p 1/2/3/4/5/6/7/8/9/10
>> + ulimit -n 7
>> ../tests/ls/recursive.sh: line 65: fcntl(1,F_DUPFD,10): Invalid argument
>
> It looks like busybox sh cannot handle that low of a file descriptor
> limit. On Alpine running the following will pass:
>
>     $ make check TESTS=./tests/ls/recursive.sh  SHELL=/bin/bash

Likewise for OpenBSD. A file descriptor limit of 20 fixes it, and seems
unlikely to cause further problems.

I'll push the attached patch tomorrow.

Thanks,
Collin


>From de4ecb749148fe38bd666628da35ac4b7ab46f97 Mon Sep 17 00:00:00 2001
Message-ID: <de4ecb749148fe38bd666628da35ac4b7ab46f97.1765607533.git.collin.fu...@gmail.com>
From: Collin Funk <[email protected]>
Date: Fri, 12 Dec 2025 21:51:30 -0800
Subject: [PATCH] tests: ls: use a larger file descriptor limit

OpenBSD and Alpine Linux /bin/sh cannot handle a file descriptor limit
of 7.

* tests/ls/recursive.sh: Create 30 directories and use a file descriptor
limit of 20. Don't check the output since we have coverage for that
elsewhere.
Reported by Bruno Haible.
---
 tests/ls/recursive.sh | 38 ++++----------------------------------
 1 file changed, 4 insertions(+), 34 deletions(-)

diff --git a/tests/ls/recursive.sh b/tests/ls/recursive.sh
index 6935bdb53..c7fe82e3a 100755
--- a/tests/ls/recursive.sh
+++ b/tests/ls/recursive.sh
@@ -61,39 +61,9 @@ compare exp out || fail=1
 
 # Check that we don't run out of file descriptors when visiting
 # directories recursively.
-mkdir -p 1/2/3/4/5/6/7/8/9/10 || framework_failure_
-(ulimit -n 7 && ls -R 1 > out) || fail=1
-cat <<EOF > exp
-1:
-2
-
-1/2:
-3
-
-1/2/3:
-4
-
-1/2/3/4:
-5
-
-1/2/3/4/5:
-6
-
-1/2/3/4/5/6:
-7
-
-1/2/3/4/5/6/7:
-8
-
-1/2/3/4/5/6/7/8:
-9
-
-1/2/3/4/5/6/7/8/9:
-10
-
-1/2/3/4/5/6/7/8/9/10:
-EOF
-
-compare exp out || fail=1
+mkdir -p $(seq 30 | tr '\n' '/') || framework_failure_
+(ulimit -n 20 && ls -R 1 > out 2> err) || fail=1
+test $(wc -l < out) = 88 || fail=1
+test $(wc -l < err) = 0 || fail=1
 
 Exit $fail
-- 
2.52.0

Reply via email to