1. Sharing file number between processes
- Posted by cp Jul 05, 2011
- 1241 views
If I open a file with one process and pass that file number to another running process say via shared memory, can the second process write to the file opened with the 1st process?
Thanks
2. Re: Sharing file number between processes
- Posted by mattlewis (admin) Jul 05, 2011
- 1259 views
If I open a file with one process and pass that file number to another running process say via shared memory, can the second process write to the file opened with the 1st process?
No. That number only means something to that instance of euphoria. Ultimately, it maps to a FILE pointer returned by fopen (part of the C std library). I don't think you could share that, either. I'd guess that you'd have to set up some protocol between your processes to have the owning file do the IO.
Matt
3. Re: Sharing file number between processes
- Posted by petelomax Jul 07, 2011
- 1132 views
No. That number only means something to that instance of euphoria.
Agreed.
Ultimately, it maps to a FILE pointer returned by fopen (part of the C std library). I don't think you could share that, either.
I think you're right about FILE too, though you can throw file handles obtained direct from the windows API between processes, I've seen that done (in C++), and that console file I/O handles can also be inherited/cloned till they work. Probably easier to close and reopen files though, if you ask me.
Regards,
Pete