some help regarding execvp

This is a discussion on some help regarding execvp within the C Programming forums, part of the General Programming Boards category; hi, i got a question. For: execl("/usr/bin/cat", "cat", "/crap data", NULL); fprintf(stderr, " error"); shldnt the fprintf be executed if ...

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,767
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  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, 11:24 AM
  3. execvp not working right
    By Nessarose in forum C Programming
    Replies: 5
    Last Post: 07-18-2005, 06: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

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