First of all: I am asking this question here, because I think this is more of a Linux question that a programming question. I have written a small C++ program, which creates a file and locks that file:#include <stdio.h>#include <sys/file.h>#include <stdlib.h>#include <errno.h>int main(int argc, char **argv) {        char ln[] = testlock.lock;        int fd = open(ln, O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);        int rc = flock(fd, LOCK_EX | LOCK_NB);        int errornumber = errno;        printf(rc: %d\n, rc);        printf(errornumber: %d\n, errornumber);        switch(errornumber) {                case EACCES:                        printf(EACCES);                        break;                case EBADF:                        printf(EBADF);                        break;                case EDEADLK:                        printf(EDEADLK);                        break;                case EINTR:                        printf(EINTR);                        break;                case EINVAL:                        printf(EINVAL);                        break;                case ENOLCK:                        printf(ENOLCK);                        break;        }        printf(\n);        return 0;}Since an upgrade, I get this output from this sample program:rc: -1errornumber: 9EBADFI found out, that it works with kernel version 3.10.0-514.26.2.el7.x86_64 (which I had before), but since 3.10.0-693.el7.x86_64 or 3.10.0-693.1.1.el7.x86_64, my sample program gives me the output above.Some questions arises: Is this a bug in the kernel itself? What has changed and where can I check that?Why that change?Additional informationOutput of cat /etc/os-release:NAME=Red Hat Enterprise Linux ServerVERSION=7.4 (Maipo)ID=rhelID_LIKE=fedoraVARIANT=ServerVARIANT_ID=serverVERSION_ID=7.4PRETTY_NAME=Red Hat Enterprise LinuxANSI_COLOR=0;31CPE_NAME=cpe:/o:redhat:enterprise_linux:7.4:GA:serverHOME_URL=https://www.redhat.com/BUG_REPORT_URL=https://bugzilla.redhat.com/REDHAT_BUGZILLA_PRODUCT=Red Hat Enterprise Linux 7REDHAT_BUGZILLA_PRODUCT_VERSION=7.4REDHAT_SUPPORT_PRODUCT=Red Hat Enterprise LinuxREDHAT_SUPPORT_PRODUCT_VERSION=7.4EditAfter the comment of xhienne, I changed my little program and this was the output of it on a newer kernel:fd: 3rc: -1errornumber: 9EBADF
RedHat: Locking of a file on NFS fails after upgrade
rhel;nfs