Hi Marcello,
try to run this code :
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/sem.h>
#define TEST_KEY 0xfaf0e001
#define SHMSIZE 200
int main(int argc, char *argv[])
{
int shmid0,
shmid1;
void *addr;
if ((shmid0 = shmget(TEST_KEY, SHMSIZE, IPC_CREAT | IPC_EXCL | 0600))
== -1)
{
perror("shmget0");
return (1);
}
printf("shmid0 = %d\n", shmid0);
addr = shmat(shmid0, (char *) NULL, 0);
memset(addr, 0, SHMSIZE);
if (shmdt(addr) == -1)
perror("shmdt0");
if ((shmid1 = shmget(TEST_KEY, SHMSIZE, 0)) == -1)
{
perror("shmget1");
if (shmctl(shmid0, IPC_RMID, (struct shmid_ds *) NULL) == -1)
perror("shmctl0");
return (2);
}
printf("shmid1 = %d\n", shmid1);
if (shmctl(shmid0, IPC_RMID, (struct shmid_ds *) NULL) == -1)
perror("shmctl0");
return (0);
}
Davide.
-- Feel free, feel Debian !- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Thu Mar 23 2000 - 21:00:28 EST