|
Message-Id: <20221112133101.253026-1-izbyshev@ispras.ru> Date: Sat, 12 Nov 2022 16:31:01 +0300 From: Alexey Izbyshev <izbyshev@...ras.ru> To: musl@...ts.openwall.com Subject: [PATCH] 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. --- src/thread/pthread_atfork.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/thread/pthread_atfork.c b/src/thread/pthread_atfork.c index 76497401..2fbe23ca 100644 --- a/src/thread/pthread_atfork.c +++ b/src/thread/pthread_atfork.c @@ -1,3 +1,4 @@ +#include <errno.h> #include <pthread.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; -- 2.37.2
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.