Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!decvax!tektronix!ogcvax!omsvax!hplabs!sri-unix!alt@BRL.ARPA From: alt@BRL.ARPA Newsgroups: net.unix-wizards Subject: r+ on fopen. Message-ID: <11771@sri-arpa.UUCP> Date: Wed, 21-Sep-83 00:50:16 EDT Article-I.D.: sri-arpa.11771 Posted: Wed Sep 21 00:50:16 1983 Date-Received: Fri, 23-Sep-83 23:04:24 EDT Lines: 44 From: Howard Alt It seems that one of our people was trying to read and write to the same file, seeking back and forth, etc. It wasn't writing the file. I solved the problem by opening 2 file descriptors to the same file, one for read, the other for append, and rewinding the append one. Then, I used ftell on the read descriptor to seek into the write desctiptor and write. It is a kluge. A person that wishes to remain unknown, did some testing, and here is what he had to say about it... ------------BEGIN FORWARDED MESSAGE To: alt hakim Subject: Seek and you shall die It appears that opening files for reading and writing simultaneously is not a working feature. I beat on the problem for a while with a little test program and noted the following behavior (see /usr/XXX/test.c): If one seeks forward an even number of bytes and then seeks backwards an even number of bytes and then writes on the file, things appear to work correctly. Things also seem to work correctly if both seeks are odd. If one seek is odd and the other even the write to the file has no effect. All of this is fairly useless; the program did fairly (random) bizarre things after only minor modification. I think the bottom line is: "read/write files are broken (QED)". We must consult the wizards, the anonymous hacker... ------------END FORWARDED MESSAGE Well, has anyone had the same experience? I really have no desire to dig through the fopen, fseek, etc code to find out what is wrong... someone must have fixed it. Please send me the fix (or even speculate on what it could be) Thanks, Howard.