From: Andre Noll Date: Sun, 22 Mar 2009 11:23:21 +0000 (+0100) Subject: Destroy the close_on_fork_list in close_listed_fds(). X-Git-Tag: v0.3.4~23 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=178acbc7280b6d4464bf0314ca348f9105366f23;hp=ab6470e0146493969887781bc8efd5a615f879c7 Destroy the close_on_fork_list in close_listed_fds(). This is called from child context and the child does no longer need the list once all fds have been closed. --- diff --git a/close_on_fork.c b/close_on_fork.c index 299aab0b..378799c7 100644 --- a/close_on_fork.c +++ b/close_on_fork.c @@ -63,16 +63,21 @@ void del_close_on_fork_list(int fd) } /** - * Call close(3) for each fd in the close-on-fork list. + * Close all fds in the list and destroy all list entries. + * + * This function calls close(3) for each fd in the close-on-fork list + * and empties the list afterwards. */ void close_listed_fds(void) { - struct close_on_fork *cof; + struct close_on_fork *cof, *tmp; if (!initialized) return; - list_for_each_entry(cof, &close_on_fork_list, node) { + list_for_each_entry_safe(cof, tmp, &close_on_fork_list, node) { PARA_DEBUG_LOG("closing fd %d\n", cof->fd); close(cof->fd); + list_del(&cof->node); + free(cof); } }