c - How to ensure that when my process is operating on a file, no other process tries to write to it or delete it? -


if process trying read file, how ensure code (c language) no other process either writes or deletes (include system commands deleting file)?

also, can achieved on os (windows, linux, solaris, hp-ux, vxworks etc)?

edit: i'll answer unix/linux

as gspr , others said, take @ file locking using fcntl, flock, etc. however, warned advisory locking methods.

what mean? means can warn other processes accesing file, or portion of it, you can't forcibly keep them ignoring , writing on file.

there no compulsory locking primitives. can use permissions advantage, you'll never have full guarantees -- root user can override limitations. don't think there's way work around that.


Comments

Popular posts from this blog

silverlight - Applying a style to ItemContainerStyle in C# -

c# - NullReferenceException in MySqlClient.NativeDriver -

php - Updating recent updates - Problem in procedure - Any other approach? -