copies of unfinished files, flushing buffers, or whatever.
Now, what does all this have to do with X applications? Let's say that you want to display an ErrorDialog upon receipt
of a signal. Here is where the problem with X and UNIX signals arises. To elaborate, we return to the call−waiting
analogy. The original telephone conversation that you were having before call waiting interrupted represents the X
protocol communication between an X client and the X server. Now, let's assume that instead of hearing a tone that
indicates there is an incoming call, you are immediately transferred to the new call without any notification. In
mid−conversation, the original caller can no longer hear you. Furthermore, when you are transferred back to the
original caller, the discussion may have progressed without your knowledge. Whatever you were saying would now
be completely confusing to anyone listening.
This situation is analogous to what happens when a UNIX signal interrupts a program that might be communicating
with the X server via the X protocol. When a UNIX signal is delivered, the operating system immediately branches to
your signal handler without notice. If you are in the middle of an X protocol message (an Xlib call) at the time of the
signal delivery, and your signal handler also calls an Xlib routine that generates another protocol message, the X
server is sent a garbled message. Basically, you started to say something and got interrupted, so now you are saying
something completely different. ...