Thread-Safe FileStreams

Andreas Raab raab at isgnw.cs.Uni-Magdeburg.DE
Mon Apr 6 19:25:56 UTC 1998


> In Unix at least, it is okay to open the same file multiple times
> within the same process.  Each open gives a completely independent
> file handle.  Closing one handle doesn't affect other handles (test
> program below, tried on Linux 2.0.33).

[C code deleted]

I've tried it from Squeak - the result is the same. However, "/dev/stdout"
is not considered to be a "regular" file. If you do the same with a usual
file handle, only the second write should show the effect. That is at
least what Squeak is doing if I try

| f1 f2 |
(FileStream newFileNamed:'blurb.bla') close. "So it's there"
f1 := FileStream oldFileNamed:'blurb.bla'.
f2 := FileStream oldFileNamed:'blurb.bla'.
f1 nextPutAll:'First hello'.
f1 close.
f2 nextPutAll:'Second hello'.
f2 close.

And that is what should happen, because at the point of creation of the
file handles the file has zero length. BTW, I didn't try from Wintel but
it should be the same unless some weird share mode has been set which is
- now that I think of it - quite possible ;-\

  Andreas
-- 
Linear algebra is your friend - Trigonometry is your enemy.
+===== Andreas Raab ============= (raab at isg.cs.uni-magdeburg.de) =====+
I Department of Simulation and Graphics      Phone: +49 391 671 8065  I
I University of Magdeburg, Germany           Fax:   +49 391 671 1164  I
+=============< http://isgwww.cs.uni-magdeburg.de/~raab >=============+





More information about the Squeak-dev mailing list