mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Alexey Izbyshev <>
Subject: [musl] [PATCH] pthread_atfork: fix return value on malloc failure
Date: Sat, 12 Nov 2022 16:31:01 +0300	[thread overview]
Message-ID: <> (raw)

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;
 	new->next = funcs;

             reply	other threads:[~2022-11-12 13:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-12 13:31 Alexey Izbyshev [this message]
2022-11-13 15:20 ` Szabolcs Nagy
2022-11-13 17:10   ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).