Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com From: "Gerald S. Williams" To: "Andrew T. Schnable" , "Robert Collins" , Subject: RE: sem_trywait returns EAGAIN (rather than returning -1 and setting errno) Date: Mon, 4 Mar 2002 11:06:02 -0500 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) Importance: Normal In-Reply-To: <001301c1c0a2$1aae73c0$6401a8c0@dopeslap2k> X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4807.1700 Andrew T. Schnable [mailto:schnable AT enteract DOT com] wrote: > I think all the sem_* functions are broken similarly. [ ... ] I just came across this myself while working on enabling Cygwin Python threads. You may find the following function helpful: static int fix_status(int status) { return (status == -1) ? errno : status; } I defined it as a routine rather than a macro so that you can use it on a single line without mistakenly calling the function twice. E.g., status = fix_status(sem_wait(thelock)); This should work for any function that returns 0 for success and -1 for failure (putting the error code in errno), since 0 is never a legal errno code. You may find it useful if you are using pthreads and semaphore code at the same time and want the return codes to work the same. -Jerry -O Gerald S. Williams, 22Y-103GA : mailto:gsw AT agere DOT com O- -O AGERE SYSTEMS, 555 UNION BLVD : office:610-712-8661 O- -O ALLENTOWN, PA, USA 18109-3286 : mobile:908-672-7592 O- -- 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/