mirror of
git://git.musl-libc.org/musl
synced 2025-03-06 20:48:29 +01:00
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.
This commit is contained in:
parent
29e4319178
commit
377218cb96
1 changed files with 2 additions and 1 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue