projects
/
musl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix logic error for skipping failed interfaces in if_nameindex
[musl]
/
src
/
thread
/
pthread_atfork.c
diff --git
a/src/thread/pthread_atfork.c
b/src/thread/pthread_atfork.c
index
0773dc8
..
95fce20
100644
(file)
--- a/
src/thread/pthread_atfork.c
+++ b/
src/thread/pthread_atfork.c
@@
-8,13
+8,14
@@
static struct atfork_funcs {
struct atfork_funcs *prev, *next;
} *funcs;
struct atfork_funcs *prev, *next;
} *funcs;
-static int lock;
+static int lock
[2]
;
-
static void
fork_handler(int who)
+
void __
fork_handler(int who)
{
struct atfork_funcs *p;
{
struct atfork_funcs *p;
+ if (!funcs) return;
if (who < 0) {
if (who < 0) {
- LOCK(
&
lock);
+ LOCK(lock);
for (p=funcs; p; p = p->next) {
if (p->prepare) p->prepare();
funcs = p;
for (p=funcs; p; p = p->next) {
if (p->prepare) p->prepare();
funcs = p;
@@
-25,7
+26,7
@@
static void fork_handler(int who)
else if (who && p->child) p->child();
funcs = p;
}
else if (who && p->child) p->child();
funcs = p;
}
- UNLOCK(
&
lock);
+ UNLOCK(lock);
}
}
}
}
@@
-34,8
+35,7
@@
int pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(vo
struct atfork_funcs *new = malloc(sizeof *new);
if (!new) return -1;
struct atfork_funcs *new = malloc(sizeof *new);
if (!new) return -1;
- LOCK(&lock);
- libc.fork_handler = fork_handler;
+ LOCK(lock);
new->next = funcs;
new->prev = 0;
new->prepare = prepare;
new->next = funcs;
new->prev = 0;
new->prepare = prepare;
@@
-43,6
+43,6
@@
int pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(vo
new->child = child;
if (funcs) funcs->prev = new;
funcs = new;
new->child = child;
if (funcs) funcs->prev = new;
funcs = new;
- UNLOCK(
&
lock);
+ UNLOCK(lock);
return 0;
}
return 0;
}