XtAppAddWorkProc() eventually requires the allocation of memory to add the new timer or work procedure to
the respective list. If your application happens to be allocating memory when a signal is delivered and you try to add a
timer or a work procedure, you could make another call to alloc(), which is the lowest−level routine that allocates
memory from the system. Unless your version of UNIX has a re−entrant memory allocation system call, your memory
stack may be corrupted. The GNU version of malloc() is re−entrant, so it is safe from this problem. There really
isn't anything that you can do about these problems, and there are no official specifications anywhere in the X
documents that even address these issues, so the best tactic is to minimize the exposure using timers or work
procedures as described here.
21.5 Summary
The official advice of the X Consortium staff is that you should not mix signals with X applications. However, there
are cases where you must choose the lesser of two evils. The need for signal handling exists and cannot simply be
ignored. In X11R6, Xt will have support for signal handlers, so this problem should no longer exist. Until then,
however, the approaches given in this chapter should serve you well most of the time.
The most important lesson to learn from this chapter may well be that UNIX signals are dangerous to X applications,
or any sort of program that relies on a client−server protocol. They can also be a problem for system calls in an
extremely sensitive or ...