Other *NIXThis forum is for the discussion of any UNIX platform that does not have its own forum. Examples would include HP-UX, IRIX, Darwin, Tru64 and OS X.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm now using HP-UX, and want to find some help.
My question is :
I create a semaphore, that's ok. Then I create it again, and a error occurs, but errno is 0. I don't know why. Have you ever gotten this problem?
Best Regards,
iclinux
Code:
semid=semget(0x12345678,1,0777|IPC_CREAT|IPC_EXCL);
if (semid == -1) return;
semid=semget(0x12345678,1,0777|IPC_CREAT|IPC_EXCL);
if (semid == -1)
{
printf("errno is [%d]\n",errno); // strange, errno is 0, why??
if (errno == EEXIST)
{
semid=semget(key,1,0);
return true;
}
else
{
return false;
}
}
I can't give you an answer for why errno is 0, because from what I read, it should be equal to EEXIST (assuming EEXIST is not defined to be 0). From the man page for semget():
Code:
RETURN VALUE
If successful, the return value will be the semaphore set identifier (a
nonnegative integer), otherwise -1 is returned, with errno indicating
the error.
ERRORS
On failure errno will be set to one of the following:
...
EEXIST A semaphore set exists for key and semflg was asserting both
IPC_CREAT and IPC_EXCL.
Moved: This thread is more suitable in "Other *nix" since it's not a linux-question, and has been moved accordingly to help your thread/question get the exposure it deserves.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.