You are not logged in.
Look:
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
#include <error.h>
int main()
{
int semid,i;
struct semid_ds semds;
key_t semkey;
if((semkey=ftok(".",1))<0)
{
perror("ftok error");
exit(1);
}
semid=semget(semkey,1,IPC_CREAT |IPC_EXCL | 0660);
if(semid==-1)
{
perror("semget error");
exit(1);
}
if(-1==semctl(semid,0,IPC_RMID,0))
{
perror("semctl RMID error");
exit(1);
}
return 0;
}
I find when I execute it at first,it run well,but since then it always
display error "File Exists",but I use command:ipcs -s not find any semaphore.
When I correct semkey=ftok(".",1) to semkey=ftok("/root",1),it always
run well.Why?How to correct it?
Offline
I am sorry, but I am obliged to ask: Is this, perchance, a homework problem ?
Last edited by ewaller (2013-03-26 01:31:17)
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way
Offline
It is not homework ,I run it in CentOS
Offline
It is not homework ,I run it in CentOS
Okay, er, I will take that at face value. Why do you ask here? I just looked back through your post history and you ask a lot of rather esoteric questions about programming. Interesting, yes. Useful to members of this forum, no. A waste of time to people who respond to you because they want to give back to Arch, yes.
Am I missing something? As a moderator, I am about to close this thread unless you can dissuade me.
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way
Offline