Hi,

it seems that in some occasions (i.e on malloc failure) pthread_create 
can return ENOMEM, which is not a valid POSIX error number.
Attached there is a patch for libpthread to normalize ENOMEM to EAGAIN.

Thanks,
-- 
Pino Toscano
From 2ee7e1e143784452ef325a0c80c106e972a3ffdc Mon Sep 17 00:00:00 2001
From: Pino Toscano <toscano.p...@tiscali.it>
Date: Sat, 15 Sep 2012 19:14:21 +0200
Subject: [PATCH] pthread_create: turn ENOMEM to EAGAIN

ENOMEM can be returned if some malloc fail, but it is not a valid POSIX error number for pthread_create;
thus turn it to EAGAIN.

* pthread/pt-create.c (pthread_create): Turn ENOMEM to EAGAIN.
---
 pthread/pt-create.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/pthread/pt-create.c b/pthread/pt-create.c
index 4d81a95..25a3607 100644
--- a/pthread/pt-create.c
+++ b/pthread/pt-create.c
@@ -66,6 +66,8 @@ pthread_create (pthread_t *thread, const pthread_attr_t *attr,
   err = __pthread_create_internal (&pthread, attr, start_routine, arg);
   if (! err)
     *thread = pthread->thread;
+  else if (err == ENOMEM)
+    err = EAGAIN;
 
   return err;
 }
-- 
1.7.10.4

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to