Thread: some help regarding execvp

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    61

    some help regarding execvp

    hi, i got a question. For:

    execl("/usr/bin/cat", "cat", "/crap data", NULL);
    fprintf(stderr, " error");

    shldnt the fprintf be executed if execl of cat fail??

  2. #2
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    No it should not. You have it set to print after its done executing. Please tell me you are a c student at a public high school.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Yes, it will print if the exec of cat fails.
    But cat attempting to open a garbage file does NOT constitute a failure to run cat itself.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Registered User
    Join Date
    Apr 2008
    Posts
    61
    ic thanks salem

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Storing the result of execvp to a char array in C
    By kponenation in forum C Programming
    Replies: 1
    Last Post: 12-14-2005, 11:43 PM
  2. Replies: 1
    Last Post: 10-27-2005, 10:24 AM
  3. execvp not working right
    By Nessarose in forum C Programming
    Replies: 5
    Last Post: 07-18-2005, 05:51 AM
  4. execvp and ampersand?
    By slevytam in forum C Programming
    Replies: 16
    Last Post: 02-02-2005, 08:36 PM
  5. getting input from keyboard, passing to execvp
    By jumpyg in forum C++ Programming
    Replies: 4
    Last Post: 11-02-2003, 08:49 PM