execl permission denied

This is a discussion on execl permission denied within the C Programming forums, part of the General Programming Boards category; I'm working on a multi-threaded proxy server and I keep getting a permission denied error when I call execl as ...

  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    2

    execl permission denied

    I'm working on a multi-threaded proxy server and I keep getting a permission denied error when I call execl as follows:

    execl(CHILD_PATH, CMD, (char*)rdy, (char*)NULL);

    I define the path and program name at the beginning of my program as follows:

    #define CHILD_PATH "./"
    #define CMD "child"

    rdy is an arguments and I terminate it with (char*)NULL. I've been trying to figure out what's wrong for close to 2 hours now and it's driving me crazy. Does anyone have any ides as to what is going wrong here?

  2. #2
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    Quote Originally Posted by http://linux.die.net/man/3/execl
    The initial argument for these functions is the pathname of a file which is to be executed.
    Your passing "./" which isnt a file, the first argument should be "./child", the file to execute.

    Your remaining arguments should be fine. Note that you do keep the second argument as "CMD", even though you already specified the path and this file as the first argument. I.e.
    Code:
    execl("./child", "child", "my arguments", (char*)NULL);
    If you still get permission denied errors, make sure the file your trying to execute can be executed, i.e. has execute permission.

  3. #3
    Registered User
    Join Date
    Nov 2009
    Posts
    2
    Thanks for the advice but I still seem to be getting an error. I changed my definitions as you recommended but now it's giving me a "bad address" error.

    Here are my updated definitions:
    #define CHILD_PATH "./child"
    #define MAIN_FILE_PATH "/mnt/hdb2/Dev-Cpp/proxy/main"
    #define CMD "child"

  4. #4
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    Can you verify that typing exactly "/mnt/hdb2/Dev-Cpp/proxy/main" (of course without quotes) at the command-line works fine with no error messages (such as the ones you are seeing when you exec)? If it works fine, can you post your (minimized) code? Basically, a small file with just the "main" function, which declares/assigns any variables needed for the call, as well as the one "execl" line of code. This will help to partition the problem (i.e. your code, vs. the file your trying to exec).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. tmpnam() : permission denied when try to open temp file
    By happyclown in forum C Programming
    Replies: 3
    Last Post: 03-16-2009, 11:48 PM
  2. Replies: 1
    Last Post: 02-10-2009, 10:02 AM
  3. Running remove() gets permission denied error...
    By edomingox in forum C Programming
    Replies: 4
    Last Post: 01-11-2009, 11:55 AM
  4. Permission Denied
    By Morgul in forum Windows Programming
    Replies: 2
    Last Post: 06-01-2005, 04:31 PM
  5. Permission Denied error
    By ChazWest in forum C Programming
    Replies: 7
    Last Post: 03-08-2002, 04:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21