aboutsummaryrefslogtreecommitdiff
path: root/src/util/signal.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/signal.c')
-rw-r--r--src/util/signal.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/util/signal.c b/src/util/signal.c
index 478551ca2..c8d6e04cd 100644
--- a/src/util/signal.c
+++ b/src/util/signal.c
@@ -39,8 +39,12 @@ struct GNUNET_SIGNAL_Context
39#endif 39#endif
40}; 40};
41 41
42#ifdef WINDOWS
43GNUNET_SIGNAL_Handler w32_sigchld_handler = NULL;
44#endif
45
42struct GNUNET_SIGNAL_Context * 46struct GNUNET_SIGNAL_Context *
43GNUNET_SIGNAL_handler_install (int signal, GNUNET_SIGNAL_Handler handler) 47GNUNET_SIGNAL_handler_install (int signum, GNUNET_SIGNAL_Handler handler)
44{ 48{
45 struct GNUNET_SIGNAL_Context *ret; 49 struct GNUNET_SIGNAL_Context *ret;
46#ifndef MINGW 50#ifndef MINGW
@@ -48,7 +52,7 @@ GNUNET_SIGNAL_handler_install (int signal, GNUNET_SIGNAL_Handler handler)
48#endif 52#endif
49 53
50 ret = GNUNET_malloc (sizeof (struct GNUNET_SIGNAL_Context)); 54 ret = GNUNET_malloc (sizeof (struct GNUNET_SIGNAL_Context));
51 ret->sig = signal; 55 ret->sig = signum;
52 ret->method = handler; 56 ret->method = handler;
53#ifndef MINGW 57#ifndef MINGW
54 sig.sa_handler = (void *) handler; 58 sig.sa_handler = (void *) handler;
@@ -58,7 +62,12 @@ GNUNET_SIGNAL_handler_install (int signal, GNUNET_SIGNAL_Handler handler)
58#else 62#else
59 sig.sa_flags = SA_RESTART; 63 sig.sa_flags = SA_RESTART;
60#endif 64#endif
61 sigaction (signal, &sig, &ret->oldsig); 65 sigaction (signum, &sig, &ret->oldsig);
66#else
67 if (signum == GNUNET_SIGCHLD)
68 w32_sigchld_handler = handler;
69 else
70 signal (signum, handler);
62#endif 71#endif
63 return ret; 72 return ret;
64} 73}