LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > Other *NIX
User Name
Password
Other *NIX This 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


Reply
  Search this Thread
Old 06-15-2005, 12:59 AM   #1
iclinux
Member
 
Registered: Dec 2004
Posts: 69

Rep: Reputation: 15
a strange question about "semget"


hi,there,

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;
        }
    }
 
Old 06-15-2005, 08:58 PM   #2
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
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.
 
Old 06-15-2005, 11:58 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
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.
 
  


Reply



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
what is "sticky bit mode" , "SUID" , "SGID" augustus123 Linux - General 10 08-03-2012 04:40 AM
Telling people to use "Google," to "RTFM," or "Use the search feature" Ausar General 77 03-21-2010 11:26 AM
newbie question: whats the difference between "su root", "su" and "su -&quo mojarron Slackware 9 12-07-2009 04:08 PM
"Xlib: extension "XFree86-DRI" missing on display ":0.0"." zaps Linux - Games 9 05-14-2007 03:07 PM
adsl+iptables+port forward+"-m tcp" strange problem icry0000 Linux - Networking 3 07-31-2005 09:31 PM

LinuxQuestions.org > Forums > Other *NIX Forums > Other *NIX

All times are GMT -5. The time now is 06:20 PM.

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