Hi all
there is a Windows API function as

HANDLE CreateFile(
  LPCTSTR lpFileName,
  DWORD dwDesiredAccess,
  DWORD dwShareMode,
  LPSECURITY_ATTRIBUTES lpSecurityAttributes,
  DWORD dwCreationDisposition,
  DWORD dwFlagsAndAttributes,
  HANDLE hTemplateFile

This function contains argument for share mode.. When I provide it 0 value then no other process can open/access the file already opened while created this call. That is while I have its handle opened if i try to access file through notepad.. it is restricted.
I need to have a similar working in Linux platform. I found two functions given in Linux which are fcntl() and flock() these two provides file locking facility in Linux. But I have tested it by opening a file and then locking it using fcntl() but then when i open the same file through editor or open() system call it is opened and locking is not functional . I need you people's help. I want to have a lock on the file that no process shall be able to open the file while is is locked. plz help me out and suggest me what i am missing.

On *nix all you have to do is pass the right arguments in the open statement and it will work the same way as CreateFile() odes. check your compiler to see if it has fsopen() because I'm not sure if that function is standard C or not.