-
Notifications
You must be signed in to change notification settings - Fork 35
/
magick.c
82 lines (75 loc) · 1.54 KB
/
magick.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <magick/api.h>
static void magick_fix_signal(int signum)
{
struct sigaction st;
if (sigaction(signum, NULL, &st) < 0) {
goto fix_signal_error;
}
st.sa_flags |= SA_ONSTACK;
if (sigaction(signum, &st, NULL) < 0) {
goto fix_signal_error;
}
return;
fix_signal_error:
fprintf(stderr, "error fixing handler for signal %d, please "
"report this issue to "
"https://github.com/rainycape/magick: %s\n",
signum, strerror(errno));
}
static void magick_fix_signals()
{
#if defined(SIGCHLD)
magick_fix_signal(SIGCHLD);
#endif
#if defined(SIGHUP)
magick_fix_signal(SIGHUP);
#endif
#if defined(SIGINT)
magick_fix_signal(SIGINT);
#endif
#if defined(SIGQUIT)
magick_fix_signal(SIGQUIT);
#endif
#if defined(SIGABRT)
magick_fix_signal(SIGABRT);
#endif
#if defined(SIGFPE)
magick_fix_signal(SIGFPE);
#endif
#if defined(SIGTERM)
magick_fix_signal(SIGTERM);
#endif
#if defined(SIGBUS)
magick_fix_signal(SIGBUS);
#endif
#if defined(SIGSEGV)
magick_fix_signal(SIGSEGV);
#endif
#if defined(SIGXCPU)
magick_fix_signal(SIGXCPU);
#endif
#if defined(SIGXFSZ)
magick_fix_signal(SIGXFSZ);
#endif
}
void magick_init()
{
#ifdef _MAGICK_USES_GM
InitializeMagick(NULL);
#else
MagickCoreGenesis(NULL, MagickTrue);
#endif
magick_fix_signals();
}
void magick_cleanup()
{
#ifdef _MAGICK_USES_GM
DestroyMagick();
#else
MagickCoreTerminus();
#endif
}