diff options
author | Alexey Izbyshev <izbyshev@ispras.ru> | 2022-11-12 16:31:01 +0300 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2022-11-12 12:22:38 -0500 |
commit | 377218cb963aa20c6eb91781b0c79ad606631e6f (patch) | |
tree | f7791947b438af0d1daa2cb7093edd40fb477b40 /src | |
parent | 29e4319178cbc2a4e9f058a99ae8098d4b6ac055 (diff) | |
download | musl-377218cb963aa20c6eb91781b0c79ad606631e6f.tar.gz musl-377218cb963aa20c6eb91781b0c79ad606631e6f.tar.bz2 musl-377218cb963aa20c6eb91781b0c79ad606631e6f.tar.xz musl-377218cb963aa20c6eb91781b0c79ad606631e6f.zip |
pthread_atfork: fix return value on malloc failure
POSIX requires pthread_atfork to report errors via its return value,
not via errno. The only specified error is ENOMEM.
Diffstat (limited to 'src')
-rw-r--r-- | src/thread/pthread_atfork.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/thread/pthread_atfork.c b/src/thread/pthread_atfork.c index 76497401..6d348ac8 100644 --- a/src/thread/pthread_atfork.c +++ b/src/thread/pthread_atfork.c @@ -1,4 +1,5 @@ #include <pthread.h> +#include <errno.h> #include "libc.h" #include "lock.h" @@ -34,7 +35,7 @@ void __fork_handler(int who) int pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void)) { struct atfork_funcs *new = malloc(sizeof *new); - if (!new) return -1; + if (!new) return ENOMEM; LOCK(lock); new->next = funcs; |