#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#define TEST_FILE "00000.txt"
int main(int argc, char *argv[])
{
if (fcntl(fd, F_SETLKW, &fl) == -1) {
perror("C:fcntl");
exit(1);
}
printf("C:locked...\n");
fl.l_type = F_UNLCK;
if (fcntl(fd, F_SETLK, &fl) == -1) {
perror("C:fcntl");
exit(1);
}
printf("C:Unlocked.\n");
if (fcntl(fd, F_SETLKW, &fl) == -1) {
perror("F:fcntl");
exit(1);
}
printf("F:locked...\n");
sleep(2);
fl.l_type = F_UNLCK;
if (fcntl(fd, F_SETLK, &fl) == -1) {
perror("F:fcntl");
exit(1);
}
printf("F:Unlocked.\n");
}