This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

sem_trywait returns EAGAIN (rather than returning -1 and setting errno)


Greetings,

    I was doing some pthreads/semaphore work and I tracked down a
problem in my code to a bug in sem_trywait.  Posix sem_trywait is defined as
returning -1 and setting errno to EAGAIN if the semaphore would have
blocked.
The cygwin implementation returns EAGAIN an leaves errno unchanged.

    Has anyone else encountered this problem and provided a fix?

Andy
schnable@enteract.com

PS. The problem seems to be in thread.cc (semaphore::TryWait) -  I don't see
much
stderr setting anywhere in this file - is this verboten - or just
overlooked?


int
semaphore::TryWait ()
{
  /*FIXME: signals should be able to interrupt semaphores...
   *We probably need WaitForMultipleObjects here.
   */
  if (WaitForSingleObject (win32_obj_id, 0) == WAIT_TIMEOUT)
    return EAGAIN;
  currentvalue--;
  return 0;
}


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]