Problem in pthread_key_create

Johnny Willemsen
Sun Jan 9 17:32:00 GMT 2005


Posted this last Friday but didn't got anything back. I think this is a bug
in the pthread library of Cygwin. Can someone have a look at this?


-----Original Message-----
From: Johnny Willemsen [] 
Sent: vrijdag 7 januari 2005 14:57
To: ''
Subject: Question about pthread_key_create

Hi all,

A question, I had a look at the implementation of pthread_key_create. When
an invalid key is passed, a EBUSY is returned. This looks very strange to
me, isn't it better to return EINVAL just as the pthread_key_delete does?
Also, shouldn't be the check be 
  if (!pthread_key::is_good_object (key))
    return EINVAL;

Note the !, when previously a good key was passed, we got back a EBUSY. 


Johnny Willemsen
Remedy IT
Leeghwaterstraat 25
2811 DT Reeuwijk
The Netherlands / 

* Thread Specific Data */
extern "C" int
pthread_key_create (pthread_key_t *key, void (*destructor) (void *))
  /* The opengroup docs don't define if we should check this or not,
     but creation is relatively rare.  */
  if (pthread_key::is_good_object (key))
    return EBUSY;

  *key = new pthread_key (destructor);

  if (!pthread_key::is_good_object (key))
      delete (*key);
      *key = NULL;
      return EAGAIN;
  return 0;

extern "C" int
pthread_key_delete (pthread_key_t key)
  if (!pthread_key::is_good_object (&key))
    return EINVAL;

  delete (key);
  return 0;

Unsubscribe info:
Problem reports:

More information about the Cygwin mailing list