fcntl
为是么fcntl(fd,F_GETLK,&lock)每次都返回-1?
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
int main(){
int fd,tmp;
struct flock f;
f.l_type=F_WRLCK;
f.l_start=0;
f.l_whence=SEEK_SET;;
f.l_len=0;
fd=open("a.txt",O_WRONLY);
tmp=fcntl(fd,F_GETLK,&f);
printf("%d\n",tmp);
if(f.l_type==F_UNLCK)
{
printf("unlock!\n");
}
return 0;
}