>cat tst.pl
use warnings;
use strict;
use Fcntl qw/:flock/;
open SELF, "< $0" or die ;
flock SELF, LOCK_EX | LOCK_NB or die "$!";
####
>perl tst.pl
A file descriptor does not refer to an open file. at tst.pl line 7.
####
.
.
.
389372: open("tst.pl", O_RDONLY|O_LARGEFILE) = 3
389372: kioctl(3, 22528, 0x00000000, 0x00000000) Err#25 ENOTTY
389372: fstatx(3, 0x30020848, 128, 010) = 0
389372: kfcntl(3, F_SETFD, 0x00000001) = 0
389372: kfcntl(3, F_SETLK, 0x2FF222A0) Err#9 EBADF
389372: access("/usr/lib/nls/msg/en_GB/libc.cat", 0) Err#2 ENOENT
389372: access("/usr/lib/nls/msg/en_US/libc.cat", 0) = 0
389372: _getpid() = 389372
389372: open("/usr/lib/nls/msg/en_US/libc.cat", O_RDONLY) = 4
389372: kioctl(4, 22528, 0x00000000, 0x00000000) Err#25 ENOTTY
389372: kfcntl(4, F_SETFD, 0x00000001) = 0
389372: kioctl(4, 22528, 0x00000000, 0x00000000) Err#25 ENOTTY
389372: kread(4, "\0\001 �\007\007 I S O 8".., 4096) = 4096
389372: lseek(4, 0, 1) = 4096
389372: lseek(4, 0, 1) = 4096
389372: lseek(4, 0, 1) = 4096
389372: _getpid() = 389372
389372: lseek(4, 0, 1) = 4096
389372: close(4) = 0
A file descriptor does not refer to an open file. at tst.pl line 7.
389372: kwrite(2, " A f i l e d e s c r".., 68) = 68
389372: kfcntl(2, F_GETFL, 0x00000008) = 1
389372: kfcntl(1, F_GETFL, 0x00000008) = 1
389372: kfcntl(2, F_GETFL, 0x00000008) = 1
389372: close(3) = 0
389372: kfcntl(2, F_GETFL, 0x00000008) = 1
####
389372: fstatx(3, 0x30020848, 128, 010) = 0
389372: kfcntl(3, F_SETFD, 0x00000001) = 0