Path: utzoo!utgpu!jarvis.csri.toronto.edu!smoke.cs.toronto.edu!neat.cs.toronto.edu!moraes Newsgroups: comp.windows.x From: moraes@cs.toronto.edu (Mark Moraes) Subject: Re: X & signals Message-ID: <90Feb25.153205est.380@smoke.cs.toronto.edu> Keywords: Don't get fancy with signals Organization: Department of Computer Science, University of Toronto References: <1154@sdrc.UUCP> Date: 25 Feb 90 20:32:35 GMT Lines: 13 As has often been pointed out before (comp.lang.c, comp.std.c, comp.std.unix) about the only thing one can do safely in a signal handler is set a flag, and return, or cleanup and exit. (Even the latter may not be quite safe, but heck, you're exiting...) Calling any procedure or touching global data is perilous -- parts of the C library are not reentrant (malloc for sure) and calling anything that might call these parts might put your application into a very confused state. I don't know how much of Xlib or Xt is re-entrant, I suspect there are non-re-entrant parts. (Perhaps a scenario where Xlib gets interrupted when packing data into a buffer, the signal handler tries to pack more data into that buffer resulting in an interleaved mess?)