Find the answer to your Linux question:
Results 1 to 3 of 3
Okay this is a real newbie question, but still I have to ask. Is there going to be any conflict if multuple instances of an app attempt to open a ...
  1. #1
    Just Joined!
    Join Date
    Dec 2009
    Posts
    13

    can multuple apps open a file at same time?

    Okay this is a real newbie question, but still I have to ask.

    Is there going to be any conflict if multuple instances of an app attempt to open a text file at the same time? And I mean open, I know multuple apps can open and read from a file at the same time, my concern is that every instance will start at the same time and attempt to open the config file at the same time. Does the file get locked temporarily while being opened to read which could result in some instances of the application failing to open the file?

    Thanks

  2. #2
    Linux Engineer GNU-Fan's Avatar
    Join Date
    Mar 2008
    Posts
    935
    A file may be unavailable for reading for quite a lot of reasons.
    Therefore every good application must take this possibility into account and be ready to deal with such a situation. Like trying again after 2 seconds or printing an error message.

    From the GNU libc manual:
    ENFILE
    The entire system, or perhaps the file system which contains the directory, cannot support any additional open files at the moment. (This problem cannot happen on the GNU system.)
    Debian GNU/Linux -- You know you want it.

  3. #3
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,970
    File locking in Linux (and Unix) is advisory-only. An application, such as Yum, might check for a file lock in order to control access to critical resources. This applies to any file, not just text files. A Linux file can be opened for read, write, read+write, append, or whatever by any number of applications, which obviously has its dangers (caveate user!). Note that if one application deletes a file (unlink), but another has opened it, then the operating system will not physically remove the file until all open and hard links to it are removed, though it can be removed from the directory it was deleted from. At the very worst, it will be "invisible" to all but those applications that still hold it open. Then when all active links to the file are closed, the file itself will be physically deleted.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...