#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
/**
int fctnl(int fd,int cmd,struct *lock); //cmd:F_SETLK设置或解放锁;F_GETLK获得锁信息;返回值:0-成功,-1-失败
struct flock{
short l_type; // of lock:F_RDLCK,F_WRLCK,F_UNLCK
short l_whence; //How to interpreter l_start:SEEK_SET,SEEK_CUR,SEEK_END
off_t l_start; //Starting offset for lock
off_t l_len; //Number of bytes to lock
pid_t l_pid; //PID of process blocking our lock(F_GETLK only)
};
*/
int main()
{
int fd;
int res;
struct flock lock = {0};