derick042497
asked on
shmget() system call
I'm facing another problem now. Does anybody have any idea what the Sun Solaris system library nsl (makefile usage -lnsl) is used for? If somebody do, what is the equivalent in the IBM AIX system?
I also have problems getting the shared memory id using the following code :
#define STKCODE_TBL_SHMKEY 7001L
#define STKCODE_HASHSIZE ( 2 * 1773 )
#define STKCODE_LEN 6
typedef struct {
char stkcode [ STKCODE_LEN+1];
int key; /* index to data */
int next; /* next entry having same hash value */
} STKCODE_TBL;
int
attach_stkcode_shm ( )
{
key_t key;
int shmid;
/* long shmsz; */
int shmsz;
key = (key_t) STKCODE_TBL_SHMKEY;
shmsz = STKCODE_HASHSIZE * sizeof ( STKCODE_TBL );
if ( ( shmid = shmget (key, shmsz, SHM_RDONLY )) == -1 ) {
perror ("shmget STKCODE_TBL ");
return (-1);
}
}
In order to get the makefile running, I'd removed the -lnsl option from the makefile in the IBM AIX. However, the system call to the shmget() function still fails.
The error message shown is as followed :
shmget STKCODE_TBL : No such file or directory
The ipcs command did show the shared memory segment was created successfully. However, I am unable to extract the shared memory id out. I hope somebody can help me out.
I also have problems getting the shared memory id using the following code :
#define STKCODE_TBL_SHMKEY 7001L
#define STKCODE_HASHSIZE ( 2 * 1773 )
#define STKCODE_LEN 6
typedef struct {
char stkcode [ STKCODE_LEN+1];
int key; /* index to data */
int next; /* next entry having same hash value */
} STKCODE_TBL;
int
attach_stkcode_shm ( )
{
key_t key;
int shmid;
/* long shmsz; */
int shmsz;
key = (key_t) STKCODE_TBL_SHMKEY;
shmsz = STKCODE_HASHSIZE * sizeof ( STKCODE_TBL );
if ( ( shmid = shmget (key, shmsz, SHM_RDONLY )) == -1 ) {
perror ("shmget STKCODE_TBL ");
return (-1);
}
}
In order to get the makefile running, I'd removed the -lnsl option from the makefile in the IBM AIX. However, the system call to the shmget() function still fails.
The error message shown is as followed :
shmget STKCODE_TBL : No such file or directory
The ipcs command did show the shared memory segment was created successfully. However, I am unable to extract the shared memory id out. I hope somebody can help me out.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.