From 377218cb963aa20c6eb91781b0c79ad606631e6f Mon Sep 17 00:00:00 2001 From: Alexey Izbyshev Date: Sat, 12 Nov 2022 16:31:01 +0300 Subject: 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(-) (limited to 'src') 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 +#include #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; -- cgit v1.2.1