signal handlers

James Bardin <[email protected]>
Newsgroups gmane.comp.video.graphicsmagick.help
Message-ID <CAB4dVTHOE9Ne1H=d0+UctCdhrLEUnhCnmRcHPNOOx3vEC1s8CA@mail.gmail.com>
Hi Bob,

When GraphicsMagick installs its signal handlers, it first replaces
the existing handler, checks if it was SIG_DFL, and reinstalls the
previous handler if it wasn't. The problem with this is that is it
doesn't set any flags that the previous handler may have had.
MagickCondSignal should probably first check if the handler is SIG_DFL
before installing a new one.

Here's an example patch to check the handler first (not really tested,
just compiled). It's not pretty since it just uses SIG_ERR to skip
reinstalling the old reinstallation step, but should show the intent:

diff -r dc00237464e4 magick/magick.c
--- a/magick/magick.c Sun Nov 08 18:30:10 2015 -0600
+++ b/magick/magick.c Tue Nov 24 10:47:23 2015 -0500
@@ -633,6 +633,12 @@
 #  if defined(SA_INTERRUPT)  /* SunOS */
   act.sa_flags |= SA_INTERRUPT;
 #  endif
+  if (sigaction(signo, NULL, &oact) < 0)
+    return (SIG_ERR);
+
+  if (oact.sa_handler != SIG_DFL)
+    return (SIG_ERR);
+
   if (sigaction(signo, &act, &oact) < 0)
     return (SIG_ERR);
   return (oact.sa_handler);

------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.