From 178acbc7280b6d4464bf0314ca348f9105366f23 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sun, 22 Mar 2009 12:23:21 +0100 Subject: [PATCH 1/1] 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. --- close_on_fork.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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); } } -- 2.39.2