Develop a C program for file-copy where two processes work together to complete the task: Parent process receives source filename and destination filename from command line. It opens the source file in read mode.
Use shared lock on the source file in both the processes. Use exclusive lock on the destination file. Do read/write operations in 256 byte blocks. You should lock as small portion of the file as possible at one time.
How do i got about when to check locks and when to put locks? I am not able to find a good resource which contains example. I tried reading it from "Beej's guide to IPC", but it doesnt have a complete example.
I know that I have to use fcntl() but how and when? Pls someone give a pseudocode of the program..