dimanche 31 juillet 2016

mq_open giving "too many open files"

I created a message queue with following code. First few times it works properly.

int main()
{
    mqd_t mqdes;
    char mq_name[10] = "/mq";
    int oflag = O_CREAT | O_RDWR, ret;
    struct mq_attr attr;

    attr.mq_maxmsg = 1024;
    attr.mq_msgsize = 2048; 

    mqdes = mq_open(mq_name, oflag, 0766, &attr);
    if(mqdes == -1) {
            perror("mq_open");
            if(errno == EMFILE)
                    perror("EMFILE");
            exit(1);
    }

    printf("mqueue created, mq_descriptor: %dn", mqdes);

    ret = mq_close(mqdes);
    if(ret == -1) {
            perror("mq_close");
            exit(2);
    }
    printf(" mq closed successfuln");


    return 0;
}

After that, it's giving following error

mq_open: Too many open files
EMFILE: Too many open files

But why i'm getting this error? How can I see possix message queues like ipcs is for system V?

Aucun commentaire:

Enregistrer un commentaire