projects
/
paraslash.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Use non-blocking API for signal handling.
[paraslash.git]
/
close_on_fork.c
diff --git
a/close_on_fork.c
b/close_on_fork.c
index 839802b8fd45d5420510eab20f926528c21dbad2..ac204e37db48d3647914bb96ccf68d8a87834d0b 100644
(file)
--- a/
close_on_fork.c
+++ b/
close_on_fork.c
@@
-1,10
+1,13
@@
/*
/*
- * Copyright (C) 2005-20
06
Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2005-20
10
Andre Noll <maan@systemlinux.org>
*
* Licensed under the GPL v2. For licencing details see COPYING.
*/
*
* Licensed under the GPL v2. For licencing details see COPYING.
*/
-/** \file close_on_fork.c manage a list of fds that should be closed on fork */
+/** \file close_on_fork.c Manage a list of fds that should be closed on fork. */
+
+#include <regex.h>
+
#include "para.h"
#include "list.h"
#include "string.h"
#include "para.h"
#include "list.h"
#include "string.h"
@@
-13,21
+16,21
@@
static struct list_head close_on_fork_list;
static int initialized;
/**
static int initialized;
/**
- *
describes an element of the close-on-fork list
+ *
Describes an element of the close-on-fork list.
*
* \sa list.h
*/
struct close_on_fork {
*
* \sa list.h
*/
struct close_on_fork {
- /**
the file descriptor which should be closed after fork()
*/
+ /**
The file descriptor which should be closed after fork().
*/
int fd;
int fd;
- /**
the position in the close-on-fork list
*/
+ /**
The position in the close-on-fork list.
*/
struct list_head node;
};
/**
struct list_head node;
};
/**
- *
add one file descriptor to the close-on-fork list
+ *
Add one file descriptor to the close-on-fork list.
*
*
- * \param fd
the file descriptor to add
+ * \param fd
The file descriptor to add.
*/
void add_close_on_fork_list(int fd)
{
*/
void add_close_on_fork_list(int fd)
{
@@
-41,11
+44,10
@@
void add_close_on_fork_list(int fd)
para_list_add(&cof->node, &close_on_fork_list);
}
para_list_add(&cof->node, &close_on_fork_list);
}
-
/**
/**
- *
delete one file descriptor from the close-on-fork list
+ *
Delete one file descriptor from the close-on-fork list.
*
*
- * \param fd
the file descriptor to delete
+ * \param fd
The file descriptor to delete.
*
* Noop if \a fd does not belong to the close-on-fork list.
*/
*
* Noop if \a fd does not belong to the close-on-fork list.
*/
@@
-64,16
+66,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)
{
*/
void close_listed_fds(void)
{
- struct close_on_fork *cof;
+ struct close_on_fork *cof
, *tmp
;
if (!initialized)
return;
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);
PARA_DEBUG_LOG("closing fd %d\n", cof->fd);
close(cof->fd);
+ list_del(&cof->node);
+ free(cof);
}
}
}
}