]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
base-files: avoid rm error messages in failsafe_wait 22079/head
authorOliver Sedlbauer <os@dev.tdt.de>
Tue, 20 Jan 2026 12:54:12 +0000 (13:54 +0100)
committerChristian Marangi <ansuelsmth@gmail.com>
Wed, 4 Mar 2026 11:54:16 +0000 (12:54 +0100)
The fs_wait_for_key function runs multiple background processes that all
try to delete the same temporary file ($keypress_wait) when they exit.
This creates a race condition where one process successfully deletes the
file while others fail with ENOENT.

Busybox rm only suppresses "file not found" errors during the initial lstat()
check, not during the actual unlink() call. This causes error messages in the
boot log even with rm -f:

  rm: can't remove '/tmp/tmp.hKjPDH': No such file or directory

Fixed by redirecting stderr to /dev/null for rm calls in concurrent contexts.
This change does not affect functionality and only avoids confusing log
output during boot.

Signed-off-by: Oliver Sedlbauer <os@dev.tdt.de>
Link: https://github.com/openwrt/openwrt/pull/22079
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
package/base-files/files/lib/preinit/30_failsafe_wait

index c792089ece1a56abe91d55d1ecf737ee3b32d582..694419aa8c6de3ddf1c70373f64e3f4c97af005f 100644 (file)
@@ -21,8 +21,8 @@ fs_wait_for_key () {
                touch $keypress_sec
        fi
 
-       trap "echo 'true' >$keypress_true; lock -u $keypress_wait ; rm -f $keypress_wait" INT
-       trap "echo 'true' >$keypress_true; lock -u $keypress_wait ; rm -f $keypress_wait" USR1
+       trap "echo 'true' >$keypress_true; lock -u $keypress_wait ; rm -f $keypress_wait 2>/dev/null" INT
+       trap "echo 'true' >$keypress_true; lock -u $keypress_wait ; rm -f $keypress_wait 2>/dev/null" USR1
 
        [ -n "$timeout" ] || timeout=1
        [ $timeout -ge 1 ] || timeout=1
@@ -37,7 +37,7 @@ fs_wait_for_key () {
                        sleep 1
                done
                lock -u $keypress_wait
-               rm -f $keypress_wait
+               rm -f $keypress_wait 2>/dev/null
        } &
 
        local consoles="$(cat /sys/class/tty/console/active)"
@@ -68,7 +68,7 @@ fs_wait_for_key () {
                                                ;;
                                        esac
                                        lock -u $keypress_wait
-                                       rm -f $keypress_wait
+                                       rm -f $keypress_wait 2>/dev/null
                                }
                        done
                } &