diff options
Diffstat (limited to 'src/util/child_management.c')
-rw-r--r-- | src/util/child_management.c | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/src/util/child_management.c b/src/util/child_management.c index 7edc33dc1..7775bfc3d 100644 --- a/src/util/child_management.c +++ b/src/util/child_management.c | |||
@@ -86,6 +86,10 @@ maint_child_death (void *cls) | |||
86 | 86 | ||
87 | (void) cls; | 87 | (void) cls; |
88 | sig_task = NULL; | 88 | sig_task = NULL; |
89 | |||
90 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
91 | "Received SIGCHLD.\n"); | ||
92 | |||
89 | /* drain pipe */ | 93 | /* drain pipe */ |
90 | pr = GNUNET_DISK_pipe_handle (sigpipe, | 94 | pr = GNUNET_DISK_pipe_handle (sigpipe, |
91 | GNUNET_DISK_PIPE_END_READ); | 95 | GNUNET_DISK_PIPE_END_READ); |
@@ -150,17 +154,37 @@ sighandler_child_death (void) | |||
150 | } | 154 | } |
151 | 155 | ||
152 | 156 | ||
153 | void __attribute__ ((constructor)) | 157 | // void __attribute__ ((constructor)) |
158 | static void | ||
154 | child_management_start () | 159 | child_management_start () |
155 | { | 160 | { |
161 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
162 | "Trying to start child management.\n"); | ||
156 | if (NULL != sigpipe) | 163 | if (NULL != sigpipe) |
157 | return; /* already initialized */ | 164 | return; /* already initialized */ |
158 | sigpipe = GNUNET_DISK_pipe (GNUNET_DISK_PF_NONE); | 165 | sigpipe = GNUNET_DISK_pipe (GNUNET_DISK_PF_NONE); |
159 | GNUNET_assert (sigpipe != NULL); | 166 | GNUNET_assert (sigpipe != NULL); |
160 | shc_chld = | 167 | shc_chld = |
161 | GNUNET_SIGNAL_handler_install (GNUNET_SIGCHLD, &sighandler_child_death); | 168 | GNUNET_SIGNAL_handler_install (GNUNET_SIGCHLD, &sighandler_child_death); |
169 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
170 | "Child management started.\n"); | ||
162 | } | 171 | } |
163 | 172 | ||
173 | /** | ||
174 | * Clean up. | ||
175 | */ | ||
176 | // void __attribute__ ((destructor)) | ||
177 | static void | ||
178 | child_management_done () | ||
179 | { | ||
180 | GNUNET_assert (NULL == sig_task); | ||
181 | GNUNET_SIGNAL_handler_uninstall (shc_chld); | ||
182 | shc_chld = NULL; | ||
183 | GNUNET_DISK_pipe_close (sigpipe); | ||
184 | sigpipe = NULL; | ||
185 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
186 | "Child management stopped.\n"); | ||
187 | } | ||
164 | 188 | ||
165 | struct GNUNET_ChildWaitHandle * | 189 | struct GNUNET_ChildWaitHandle * |
166 | GNUNET_wait_child (struct GNUNET_OS_Process *proc, | 190 | GNUNET_wait_child (struct GNUNET_OS_Process *proc, |
@@ -189,7 +213,6 @@ GNUNET_wait_child (struct GNUNET_OS_Process *proc, | |||
189 | return cwh; | 213 | return cwh; |
190 | } | 214 | } |
191 | 215 | ||
192 | |||
193 | void | 216 | void |
194 | GNUNET_wait_child_cancel (struct GNUNET_ChildWaitHandle *cwh) | 217 | GNUNET_wait_child_cancel (struct GNUNET_ChildWaitHandle *cwh) |
195 | { | 218 | { |
@@ -198,22 +221,9 @@ GNUNET_wait_child_cancel (struct GNUNET_ChildWaitHandle *cwh) | |||
198 | cwh); | 221 | cwh); |
199 | if (NULL == cwh_head) | 222 | if (NULL == cwh_head) |
200 | { | 223 | { |
224 | child_management_done (); | ||
201 | GNUNET_SCHEDULER_cancel (sig_task); | 225 | GNUNET_SCHEDULER_cancel (sig_task); |
202 | sig_task = NULL; | 226 | sig_task = NULL; |
203 | } | 227 | } |
204 | GNUNET_free (cwh); | 228 | GNUNET_free (cwh); |
205 | } | 229 | } |
206 | |||
207 | |||
208 | /** | ||
209 | * Clean up. | ||
210 | */ | ||
211 | void __attribute__ ((destructor)) | ||
212 | GNUNET_CM_done () | ||
213 | { | ||
214 | GNUNET_assert (NULL == sig_task); | ||
215 | GNUNET_SIGNAL_handler_uninstall (shc_chld); | ||
216 | shc_chld = NULL; | ||
217 | GNUNET_DISK_pipe_close (sigpipe); | ||
218 | sigpipe = NULL; | ||
219 | } | ||