fcntl
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
int main(int argc, char* argv[])
{
char* file = argv[1];
int fd;
struct flock lock;
lock.l_type = F_WRLCK;
lock.l_start = 0;
lock.l_whence = SEEK_SET;
lock.l_len = 50;
printf("Please insert your file : ");
scanf("%s", file);
fd = open (file, O_WRONLY);
printf ("locking\n");
memset (&lock, 0, sizeof(lock));
lock.l_type = F_WRLCK;
pause();
return 0;
}
can anyone help me..??
i can compile the program but cant lock file...
WHY...??
|