LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   how to read the same file? (https://www.linuxquestions.org/questions/linux-kernel-70/how-to-read-the-same-file-643441/)

peterhuang 05-20-2008 03:28 AM

how to read the same file?
 
I need to use many different programs to open the same file.But When i use command "lsof" to check the open files, every program has open one file. it causes that file is opened too many times. how to let the file to be shared to every program and the file just only be opened one times.

PS. I want to open one file at one time for all different program on UNIX.

thanks

b0uncer 05-20-2008 03:43 AM

Maybe if your programs opened the file (for reading), read the contents (or parts that are needed) and then closed the file? At least some programs (for example some text editors) work on a copy of a file rather than have the file open all the time, to prevent situations where the same file is opened by many programs at once. Then they just need to keep track about file changes so that if some other program altered the file already, the program could warn the user that the file is already changed (and saving to it will overwrite any previous changes made).

peterhuang 05-20-2008 11:30 PM

Sorry , I should change my title to "how to open the same file".
Every opened file has only one fd(file description). I want to all different program can get the same fd to do IO process.
It can reduce the number of open file .
how can i do?

If this method can be implemented, can it reduce resource (memory, cpu ...) consumption?


All times are GMT -5. The time now is 02:40 PM.