POSIX requires pthread_atfork to report errors via its return value,
not via errno. The only specified error is ENOMEM.
#include "libc.h"
#include "lock.h"
#include "libc.h"
#include "lock.h"
int pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void))
{
struct atfork_funcs *new = malloc(sizeof *new);
int pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void))
{
struct atfork_funcs *new = malloc(sizeof *new);
+ if (!new) return ENOMEM;
LOCK(lock);
new->next = funcs;
LOCK(lock);
new->next = funcs;