On 7 August 2013 03:44, Zbigniew Halas <[email protected]> wrote: > On Wednesday, August 07, 2013 02:23:38 AM Jiří Zárevúcky wrote: >> On 7 August 2013 02:08, Jakub Klama <[email protected]> wrote: >> > On Wed, 07 Aug 2013 01:40:35 +0200, Jiřà Zárevúcky wrote: >> >> The thing is, I never figured out any reason this would be even >> >> remotely useful. On the other hand, not supporting this kind of >> >> sharing allows to make certain simplifications in the code. You could >> >> also move dealing with position from the server to client (I did that >> >> in my original VFS2 branch). >> >> >> >> So I'd like a second (or third, or fourth, ...) opinion. >> >> 1) Have you ever seen this feature used practically in a POSIX program? >> > >> > dup2() is widely used as simple stdin/stdout redirection. Following code >> > redirects standard output to file "output.txt" by replacing stdout >> >> > descriptor with newly opened descriptor: >> Please refer to the last paragraph of my original post. > > Sharing the file offset between two file descriptors is crucial for POSIX > shell output redirection semantics when two streams are redirected to the same > file. Otherwise the data from one stream could be overwritten by the data from > the other stream due to offset mismatch. > Also I'm not saying that keeping this behavior in HelenOS is important, just > saying how it's done in POSIX. >
Thanks for comments. In the normal case, standard output should be open for appending. If both tasks append, there is no position to synchronize. The only case in which the position is relevant is when you want to overwrite a part of file by the output while keeping all the higher-position parts intact, which I think is obscure enough to ignore. If really necessary, you can do it with pipes anyway. This applies to Jakub J.'s comment as well. As far as I can tell, there is never a situation in which you want two tasks write concurrently in the middle of a file. Am I wrong? What about reading? Is it ever useful to have multiple tasks to read a single file with a shared pointer? -- Jirka Z. _______________________________________________ HelenOS-devel mailing list [email protected] http://lists.modry.cz/listinfo/helenos-devel
