We've got problems in the signal handlers.

Signal handlers seem to be set in 3 files.  The good news:

- util.c is all safe
- menus.c is safe

ctwm.c, however, is a different story.  

- SIGCHLD handler is safe, yay.
- SIGHUP handler is doing a fprintf() which isn't async-signal-safe.
  Fortunately, that's merely cosmetic and can be pretty easily yanked.
- SIGSEGV/BUS (Crash()) catcher is doing a lot of fprintf()'s, which
  aren't safe (but are merely informative and could be dropped).
  However, it's also calling out both indirectly and directly to Xlib
  functions(!!!) which have to be about the LEAST async-signal-safe
  functions you could find in the wild.
- SIGINT/QUIT/TERM handler (Done()) commits all the above atrocities,
  and heaps on top the potential of calling out to *SOUND* playing
  functions.  Caramba!


The SIGHUP handler can be trivially made safe.

The Crash() handler, I think, should just be removed; the "clean
cleanup" stuff can't be done in the signal handler, and can't possibly
be safely done at that point anyway since we're already in an
ill-defined state.  The begging of the user to send a stack trace
can't be done safely in the signal handler, and the trace is likely
corrupted already by jumping around the signal handlers.

Done() probably needs to be switched to just calling _exit(2) (not
exit(3)).  A somewhat more involved possibility would be to set a flag
we can check to do the more clean-like shutdown off in the main loop
(which is probably the better choice, but is more work).


Thoughts?


-- 
Matthew Fuller     (MF4839)   |  [EMAIL PROTECTED]
Systems/Network Administrator |  http://www.over-yonder.net/~fullermd/
           On the Internet, nobody can hear you scream.

Reply via email to