🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.sun
Article #6511

Semctl problem on SunOS 4.0.3c

#6511
From: Graham Bardsley
Date: Mon, 14 Jan 1991 21:57
59 lines
1969 bytes
Is there anything at all wrong with the following code? When it's run on a
Sparc 1+ running 4.0.3c (EXPORT I presume), it fails with the message :
`Sem create failed: Bad address' from the return from the IPC_STAT.  It
similarly fails if an IPC_SET is attempted. It works fine on Sun3.  I've
looked at the bug lists we have here but find no mention of it, so should
I report this or what??

#include <stdio.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>

static struct semid_ds ctlbuf;

int SemCreate(key, val)
int key;
int val;
{
        int id;
        int status;
        struct sembuf op;

        if ((id=semget((key_t) key,
                       1,
                       IPC_CREAT | 0666)) == -1)
        {
                return -1;
        }

        if (semctl(id, 0, IPC_STAT, &ctlbuf) == -1)	/* Fails here */
        {
                semctl(id,
                      0,
                      IPC_RMID,
                      0);
                return -1;
        }

        return id;

}


int
main(argv,argc)
char **argc;
{
        int sem=SemCreate(123,1);

        if (sem == -1)
        {
                perror("Sem create failed");
                exit(1);
        }
        exit(0);
}

Graham Bardsley,STC Telecoms,Oakleigh Road South,New Southgate, London, N11 1HB
..{uunet,mcsun}!ukc!stc!graham   <graham@tcom.stc.co.uk>  Tel: +44 81 945 3799
Technical Details
Message-ID: <1254@brchh104.bnr.ca>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!cunews!bnrgate!brtph3!brchh104!brchs1!bnr.ca!rice.edu!sun-spots-request

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!cunews!bnrgate!brtph3!brchh104!brchs1!bnr.ca!rice.edu!sun-spots-request
From: graham@tcom.stc.co.uk (Graham Bardsley)
Newsgroups: comp.sys.sun
Subject: Semctl problem on SunOS 4.0.3c
Keywords: Miscellaneous
Message-ID: <1254@brchh104.bnr.ca>
Date: 14 Jan 91 21:57:58 GMT
Sender: news@brchh104.bnr.ca
Organization: Sun-Spots
Lines: 59
Approved: Sun-Spots@rice.edu
X-Sun-Spots-Digest: Volume 10, Issue 19, message 19
X-Note: Submissions: sun-spots@rice.edu, Admin: sun-spots-request@rice.edu