]> Sergey Matveev's repositories - public-inbox.git/commitdiff
t/lei-watch: avoid race between glob + readlink
authorEric Wong <e@80x24.org>
Tue, 31 Aug 2021 11:21:21 +0000 (11:21 +0000)
committerEric Wong <e@80x24.org>
Tue, 31 Aug 2021 11:29:10 +0000 (11:29 +0000)
Open file handles in lei-daemon may be unstable so we need to
account for readlink() returning undef.

t/lei-watch.t

index 86fa66493920d47c575335a4ede49ce7196f183d..a881fbb9c05ccb310cd09d657c9b3e210c9a17aa 100644 (file)
@@ -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];