arg.val = 1;
if (sem_id = semget(IPC_PRIVATE, 1, 0600 | IPC_CREAT) == -1 ){
perror("Creating semaphore failed");
exit(1);
}
else {
printf("Creating a semaphore with ID: %d \n",sem_id);
if (semctl(sem_id, 0, SETVAL, arg) == -1 ) {
perror("Initialization of semaphore failed\n");
exit(1);
}
}
我正在尝试创建和初始化一个信号量,当我编译我的程序时它返回我:
“信号量初始化失败:标识符已删除
你能解释一下发生这种情况的原因吗?