Path: utzoo!utgpu!attcan!uunet!ginosko!brutus.cs.uiuc.edu!apple!agate!ucbvax!husc6!cmcl2!yale!cs.yale.edu!spolsky-joel@CS.YALE.EDU From: spolsky-joel@CS.YALE.EDU (Joel Spolsky) Newsgroups: comp.unix.questions Subject: Re: Are terminal writes atomic? Message-ID: <1118@cs.yale.edu> Date: 1 Oct 89 20:56:50 GMT References: <-286379999@hpcupt1.HP.COM> Sender: news@cs.yale.edu Reply-To: spolsky-joel@CS.YALE.EDU (Joel Spolsky) Organization: Yale University Computer Science Dept, New Haven CT 06520-2158 Lines: 26 In article <-286379999@hpcupt1.HP.COM> stratton@hpcupt1.HP.COM (Jim Stratton) writes: >I have two processes doing simultaneous output to the same terminal using the >write system call. Assume A does a write of 10 bytes while B does a write >of 30 bytes. Can I be assured that A's and B's output will not be inter- >mixed? I understand that for pipes, they won't be mixed. How about terminals? >-- >Jim Stratton hplabs.hp.com!hpcupt1!stratton I think this is safe. A while ago I wrote a little program that runs on a Unix host, and puts the time, date, and warns you if you get mail in the status line of TVI950's or VT100's. This program runs quitely in the background, and every once in a while sends the necessary string to the terminal. Under extensive testing, it never interfered with whatever foreground process was running, even when it had to write a whole 80 character string to the status line every second. The write() commands were preserved atomically. Now, this is on Sun-OS 4.0, it might not work on your system, and I don't know how to "prove" that it always works, but it has for me. +----------------+----------------------------------------------------------+ | Joel Spolsky | bitnet: spolsky@yalecs.bitnet uucp: ...!yale!spolsky | | | internet: spolsky@cs.yale.edu voicenet: 203-436-1538 | +----------------+----------------------------------------------------------+ #include