#define _GNU_SOURCE #include #include #include #include int main( const int argc, const char * const * const argv, const char * const * const envp ) { int fd; int result; fd = open(argv[1], O_RDWR, 0); if (fd < 0) { perror("open"); exit(1); } result = fcntl(fd, F_SETLEASE, F_WRLCK); if (result != 0) { perror("setlease wrlck"); exit(1); } usleep(10000000); result = fcntl(fd, F_SETLEASE, F_UNLCK); if (result != 0) { perror("setlease unlck"); exit(1); } result = close(fd); if (result != 0) { perror("close"); exit(1); } return 0; }