execl error

This is a discussion on execl error within the C Programming forums, part of the General Programming Boards category; i have a simple program on sun box: Code: int main() { execl("/usr/bin/date","date","0"); execl("/usr/bin/pwd","pwd","0"); } the output i get shows ...

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    7

    execl error

    i have a simple program on sun box:
    Code:
    int main()
    {
    execl("/usr/bin/date","date","0");
    execl("/usr/bin/pwd","pwd","0");
    }
    the output i get shows only the date and does not execute the pwd command. why does this happen? how can i resolve it?

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,673
    Because execl() doesn't return - which is explained in the manual page.

  3. #3
    Registered User
    Join Date
    Nov 2005
    Posts
    7
    so what should I do so that I can get both those commands going?

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,673
    Look up fork() and wait()
    Or read some examples of such functions on the Linux board.

    In very minimal pseudo-code, it's
    if ( fork() == 0 ) execl() else wait()

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Testing some code, lots of errors...
    By Sparrowhawk in forum C Programming
    Replies: 48
    Last Post: 12-15-2008, 03:09 AM
  3. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 04:45 PM
  4. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 09:33 AM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 12:10 AM

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