POSIX message queue mq_open directory

hello, I try to test the POSIX mq_open function on book unp like below:

#include "unpipc.h"
# include    <mqueue.h>

int main(int argc, char **argv)
{
    int        c, flags;
    mqd_t    mqd;

    flags = O_RDWR | O_CREAT;

    while ((c = getopt(argc, argv, "e")) != -1) {
        switch (c) {
        case 'e':
            flags |= O_EXCL;
            break;
        }
    }
    printf("optind = %d,argc = %d\n",optind,argc);
    printf("argv[optiond]: %s\n", argv[optind]);
    if (optind != argc -1)
        err_quit("usage: mqcreate [ - e ] <name>");

    if ((mqd = mq_open(argv[optind], flags, FILE_MODE, NULL)) < 0) {
        printf( "strerror says open failed: %s\n",strerror(errno));
        err_quit("create mqueue failed!\n");
    }
    else
        printf("create mqueue successful\n");
    mq_close(mqd);
    exit(0);
}

./a.out /test.1234
It works ok but I can't find where is the created mq-file(test.1234)? Does anybody know the default directory? thanks.
I am using ubuntu 10.04

As far as I know message queues aren't real files. They can be in some implementations but there's no need for them to be, and often aren't. So the name only has meaning to the kernel.

1 Like

thanks, I have found it out, I can use the command
sudo mount -t mqueue none des-dir
to mount to the file system, the "mqueue-files" I created can be found there.:smiley:

They're still not 'real' files. Like /proc/, it's a special filesystem that exists only in the kernel's imagination.