I can't figure out what I missed. The first time that I run this msgget() retuns 0 but msgctl() can remove it. The second time still having 0 and msgctl() aborts with invalid argument error.
Already tried to use some key instead of IPC_PRIVATE
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/sem.h>
#include <sys/msg.h>
#include <time.h>
#define DEBUG
int main(){
int queue_id;
if(queue_id = msgget(IPC_PRIVATE, IPC_CREAT | IPC_EXCL | 0600) == -1){
perror("queue");
return -1;
}
if(msgctl(queue_id, IPC_RMID, NULL) == -1) {
perror("queue rmid:");
}
return 0;
}