Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!sharkey!bnlux0!adelphi!promark!mark From: mark@promark.UUCP (Mark J. DeFilippis) Newsgroups: comp.unix.questions Subject: Re: Are terminal writes atomic? Summary: Opps... My goof Message-ID: <193@promark.UUCP> Date: 8 Oct 89 20:31:11 GMT References: <186@promark.UUCP> <411@hitech.ht.oz> Organization: Promark Data Concepts, Garden City, NY Lines: 50 In article <411@hitech.ht.oz>, clyde@hitech.ht.oz (Clyde Smith-Stubbs) writes: > From article <186@promark.UUCP>, by mark@promark.UUCP (Mark J. DeFilippis): > > In article <1118@cs.yale.edu>, spolsky-joel@CS.YALE.EDU (Joel Spolsky) writes: > >> I think this is safe. A while ago I wrote a little program that runs > > > > How about we take this further. The answer to this question is an > > undocumented feature of write() under Unix. Several Authors note > > that write() is atomic under Unix and that it is undocumented. > > Rubbish! Writes to terminals under Unix are not, and have never been, > in any way atomic. In many cases they will be atomic, but there > is nothing in the structure of the system to guarantee this. It is easy > [program followed] Sorry, Under my Unix system V, and my Xenix system as well as SCO UNIX system V, your program yeilds atomic writes. However, this is a coeincidence. Someone else provided a program 3 articles after yours which woke me up. Plus my boss said to me, "Mark, where is your mind? Remember that application you wrote 3 months ago and the semaphores you had to use to control simulatneous access by multiple writes?" I went back to the Rochkind book I mentioned, which I should have done in the first place, to see where my neural net got it's cross circuit. He states: "It is presumably a goal of the /usr/group standards effort to document important properties like the atomicity of creat, open, and write, But their proposed standard does not do so. If this omission is deliberate - that is, a conforming implimentation does _not_ have to ensure that these systems calls are atomic, then the standard is seriously defective." This is a footnote in the book when discussing "The Unix manual fails to state that writes to files opened with O_APPEND are atomic." However vendors are only bound by the manual for their implimentation. "Whats worse, even a system that doesn't force open and write to be atomic will still act that way 99 percent of the time, making the bug maddeningly elusive." A totally different story. Sorry about the confusion, and thanks to those whose minds were on guard for setting me straight. I should have known this stuff anyway, since I have had to impliment semaphores for exactly this reason in the past. Sometimes the mind wanders, thats one of the reasons why we have auto accidents... Again, my apologies -- Adelphi University, Garden City, NY 11530 (516) 663-1170 Department of Mathematics and Computer Science markd@adelphi.UUCP or mark@promark.UUCP UUCP: ...philabs!sbcs!bnlux0!adelphi!markd