Did you know LQ has a Linux Hardware Compatibility List?
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 10-29-2007, 09:23 AM   #1
LQ Newbie
Registered: Oct 2007
Location: Charlotte, NC
Distribution: Ubuntu 10.04, Davinci (MacOS/X)
Posts: 20

Rep: Reputation: 0
Question return code or errno?

Here is a snippet from the pthread_mutex_lock() man page

RETURN VALUE If successful, the pthread_mutex_lock() and pthread_mutex_unlock() functions return zero. Otherwise, an error number is returned to indicate the error.

Following it is a list of possible error codes, EINVAL, EBUSY, etc.

Does the help mean that one of the error codes is returned as the return code of pthread_mutex_lock() or that pthread_mutex_lock() returns non-zero (meaning what?) and sets errno to one of the error codes?


Old 10-29-2007, 09:45 AM   #2
Senior Member
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,990

Rep: Reputation: 68
The call will return the error code, or zero on success.

errno is defined in the ISO standard C library, and (if memory serves), can only be modified by certain standard function calls. Since pthread is not a part of standard C (nor is any kind of threading support), pthread should not be modifying errno.


—Robert J Lee
Old 10-29-2007, 10:23 AM   #3
LQ Newbie
Registered: Oct 2007
Location: Charlotte, NC
Distribution: Ubuntu 10.04, Davinci (MacOS/X)
Posts: 20

Original Poster
Rep: Reputation: 0
Interestingly enough, the compiler does not complain if you write:

errno = 3;

And that "other' operating system has SetLastError() and assigns a group of error numbers to be locally administerd.

But I understand your post and that makes much sense.





Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Return code of a shell script zachos.v Linux - Software 3 10-10-2006 10:51 AM
request_region(...) return code BrooklynOutlier Programming 0 03-07-2006 10:22 PM
request_region return code BrooklynOutlier Slackware 0 03-06-2006 11:26 PM
dd return code barefootdoctor Linux - General 2 10-13-2005 01:54 PM
return value from shell script to c code? khucinx Programming 1 05-13-2004 04:43 PM

All times are GMT -5. The time now is 12:08 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration