From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 281921FB06 for ; Tue, 31 Aug 2021 11:21:27 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 05/10] t/lei-watch: avoid race between glob + readlink Date: Tue, 31 Aug 2021 11:21:21 +0000 Message-Id: <20210831112126.13406-6-e@80x24.org> In-Reply-To: <20210831112126.13406-1-e@80x24.org> References: <20210831112126.13406-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Open file handles in lei-daemon may be unstable so we need to account for readlink() returning undef. --- t/lei-watch.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/lei-watch.t b/t/lei-watch.t index 86fa6649..a881fbb9 100644 --- a/t/lei-watch.t +++ b/t/lei-watch.t @@ -25,7 +25,7 @@ test_lei(sub { lei_ok 'daemon-pid'; chomp(my $pid = $lei_out); skip 'missing /proc/$PID/fd', 1 if !-d "/proc/$pid/fd"; my @ino = grep { - readlink($_) =~ /\binotify\b/ + (readlink($_) // '') =~ /\binotify\b/ } glob("/proc/$pid/fd/*"); is(scalar(@ino), 1, 'only one inotify FD'); my $ino_fd = (split('/', $ino[0]))[-1];