Permission denied when creating message queue


 
Thread Tools Search this Thread
Top Forums Programming Permission denied when creating message queue
# 1  
Old 09-14-2010
Permission denied when creating message queue

Hi guys.

i have wrote a simple program to test message queue attributes. here it is:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <mqueue.h>
#include <fcntl.h>   
#include <string.h>
#include <errno.h>
#include <sys/stat.h>

int main()
{
    struct mq_attr attr;
    mqd_t mqd;
    if ((mqd = mq_open("/tmp/queue.123", O_RDWR | O_CREAT, S_IRUSR | S_IWUSR, NULL)) == -1)
    {
        printf("damn it: %s\n", strerror(errno));
        exit(EXIT_FAILURE);
    }
    mq_getattr(mqd, &attr);
    printf("max message on queue: %ld\n", attr.mq_maxmsg);
    printf("max message size: %ld\n", attr.mq_msgsize);
    printf("current number of message on the queue: %ld\n", attr.mq_curmsgs);
    mq_close(mqd);
    mq_unlink("/tmp/queue.123");
    return EXIT_SUCCESS;
}

but when i run it always it prints:
Code:
damn it: Permission denied

I executed it under root user but again this error.
also permissions for /tmp directory is 777.
# 2  
Old 09-14-2010
From man mq_overview:

Code:
Message queues are created and opened using mq_open(3);  this  function
       returns  a  message queue descriptor (mqd_t), which is used to refer to
       the open message queue in later calls.  Each message queue  is  identi-
       fied by a name of the form /somename; that is, a null-terminated string
       of up to NAME_MAX (i.e.,  255)  characters  consisting  of  an  initial
       slash,  followed  by one or more characters, none of which are slashes.
       Two processes can operate on the same queue by passing the same name to
       mq_open(3).

Message queues aren't really files. You don't create them under /tmp/.
This User Gave Thanks to Corona688 For This Post:
# 3  
Old 09-14-2010
Thank you very much.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Ubuntu

Permission denied

Trying to get date into the txt file. It says Permission denied. echo $(date +%I:%M:%S_%D) >> /tmp/systemd_suspend_test_err.txt exec 2>> /tmp/systemd_suspend_test_err.txt if ; then # Do the thing you want before suspend here echo "we are suspending $(date +%I:%M:%S_%D)." elif ;... (5 Replies)
Discussion started by: drew77
5 Replies

2. Programming

msgget message queue always get permission denied

I want to use msgget() to obtain a message queue between two processes, here is my code: the first one create the mq, the second one open it and add a message to it. But when I execute the second one, I get permission denied. I've already desperately tried everything I can think of to solve this... (2 Replies)
Discussion started by: tefino
2 Replies

3. Programming

creating a message queue using mq_open

Hi all, First of all thanks in advance for reading my post and for your heart for helping me. I am trying to create a message queue using mq_open(name,oflags,mode_t,attr) method. But that function call is returning with an error code EFAULT. By googling it I found that it happens when there is... (10 Replies)
Discussion started by: parusasi
10 Replies

4. UNIX for Dummies Questions & Answers

Permission Denied creating file under nfs mount

I have two servers, 82 and 70. My exports file on 82 reads / ...70(rw) on 70 I have a mountpoint called mnt_for_82 I execute on 70 mount -t nfs -o rw ...82:/ mnt_for_82 I go to server 70 and indeed can read and travers the mounted subdirectories. However, I try... (0 Replies)
Discussion started by: blaine.miller
0 Replies

5. Red Hat

Permission denied

Hi guys im new to this db i have a small prob while installing websphereportal6.1i think i was installed succesfully but the error im getting is while starting server. check this out # ./serverStatus.sh -all Error loading: /usr/wps61/AppServer/java/jre/bin/classic/libjvm.so: cannot... (1 Reply)
Discussion started by: varma917989
1 Replies

6. Shell Programming and Scripting

Executing expect script giving message as bad interpreter: Permission denied

Hi Gurus, I am new to scripting and needs your help in expect script used for telnet. I wrote a simple script as #!/usr/bin/expect-5.43 -f spawn telnet localhost 2233 expect "password:" send "secret\r" send "i data.cnbc.com\r" send "exit\r" expect eof When I am trying to execute... (2 Replies)
Discussion started by: niks_yv
2 Replies

7. Solaris

Permission denied message for parent directory

Hi All, I have an issue that's eating my head for few days. I would appreciate if anyone could help me out in this to resolve this. In Solaris 8 container I am facing the below issue. As oracle user when I do ls -l in /dboracle mountpoint getting permission denied error messages. $ ls... (3 Replies)
Discussion started by: Sreerag446
3 Replies

8. Programming

How to limit max no of message in a posix message queue

Hii can anyone pls tell how to limit the max no of message in a posix message queue. I have made changes in proc/sys/fs/mqueue/msg_max But still whenever i try to read the value of max. message in the queue using attr.mq_curmsgs (where struct mq_attr attr) its giving the default value as 10.... (0 Replies)
Discussion started by: mohit3884
0 Replies

9. Programming

URGENT:::Can anybody help me in creating message queue appliction??

hello, I had to implement a message queue application....between 30 processes...... all 30 proceses are getting data from serial port.... And here is THE FLOW::::::::1 connector process...which is linked with message queue to all the 30 applications. Processes get the data from serial port and... (9 Replies)
Discussion started by: arunchaudhary19
9 Replies

10. UNIX for Advanced & Expert Users

Permission denied

Hi, I can not execute a .env file $ . /Data/oracle/d03/mydbora/8.0.6/MYDB.env -bash: /Data/oracle/d03/mydbora/8.0.6/MYDB.env: Permission denied Even if : -rwxrwxrwx 1 oracle dba 2903 Mar 5 2007 /Data/oracle/d03/mydbora/8.0.6/MYDB.env Please help. Many thanks. (1 Reply)
Discussion started by: big123456
1 Replies
Login or Register to Ask a Question

Featured Tech Videos