Thread: execl error

  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 int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    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 int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    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, 04:09 AM
  3. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  4. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 10:33 AM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 01:10 AM