/*
- * Copyright (C) 2005-2008 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2005-2009 Andre Noll <maan@systemlinux.org>
*
* Licensed under the GPL v2. For licencing details see COPYING.
*/
}
/**
- * 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);
}
}