struct atfork_funcs *prev, *next;
} *funcs;
-static int lock;
+static int lock[2];
void __fork_handler(int who)
{
struct atfork_funcs *p;
if (!funcs) return;
if (who < 0) {
- LOCK(&lock);
+ LOCK(lock);
for (p=funcs; p; p = p->next) {
if (p->prepare) p->prepare();
funcs = p;
else if (who && p->child) p->child();
funcs = p;
}
- UNLOCK(&lock);
+ UNLOCK(lock);
}
}
struct atfork_funcs *new = malloc(sizeof *new);
if (!new) return -1;
- LOCK(&lock);
+ LOCK(lock);
new->next = funcs;
new->prev = 0;
new->prepare = prepare;
new->child = child;
if (funcs) funcs->prev = new;
funcs = new;
- UNLOCK(&lock);
+ UNLOCK(lock);
return 0;
}