aboutsummaryrefslogtreecommitdiff
path: root/src/util/signal.c
diff options
context:
space:
mode:
authorNils Durner <durner@gnunet.org>2010-03-22 21:50:38 +0000
committerNils Durner <durner@gnunet.org>2010-03-22 21:50:38 +0000
commit1d943b33c95c2d3f366d50e22e8b134029d5a579 (patch)
tree14f4831dd4102b7a80ed1656b2d6f9b1e2782747 /src/util/signal.c
parente409833ea6360385d5c085643a9fa028f410d7e1 (diff)
downloadgnunet-1d943b33c95c2d3f366d50e22e8b134029d5a579.tar.gz
gnunet-1d943b33c95c2d3f366d50e22e8b134029d5a579.zip
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}