Is it possible to prevent file deletion/renaming while program has opened file descriptor. I open file with open() and then try locking it with fcntl() but i still can rename or delete file. Reading fcntl documentation it seems imposible to do.
FD = open(file_name, O_WRONLY | O_CREAT | O_EXCL, 0600);
struct flock exclusiveLock;
exclusiveLock.l_type=F_WRLCK;
exclusiveLock.l_whence=SEEK_SET;
exclusiveLock.l_len=exclusiveLock.l_start=0;
exclusiveLock.l_pid=0;
lockResult=fcntl(FD,F_SETLK,&exclusiveLock);