system commad

Discussion in 'C' started by sharathg_535, Aug 14, 2006.

  1. sharathg_535

    sharathg_535 New Member

    Joined:
    Aug 14, 2006
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    HI ,
    I am coding in C++ on linux platform.
    what system command will return , when the string entered as argument is not a
    proper shell command.
    when I given system("abc") , it is returning 256 .
    I know that if it returns -1 means that system failed to run . what 256 indicates means what positive integer return values mean ?

    Regards,
    Sharath
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Use WEXITSTATUS to get the status.
     
  3. sharathg_535

    sharathg_535 New Member

    Joined:
    Aug 14, 2006
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Could you please explain what is WEXITSTATUS ...
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    WEXITSTATUS-Obtain exit status of a child process
    This macro queries the child termination status provided by the wait and waitpid functions. If the WIFEXITED macro indicates that the child process exited normally, the WEXITSTATUS macro returns the exit code specified by the child process.

    status
    The status field that was filled in by the wait or waitpid function.

    Normal return
    The WEXITSTATUS macro is always successful.

    If the WIFEXITED macro indicates that the child process exited normally, the WEXITSTATUS macro returns the exit code specified by the child. If the WIFEXITED macro indicates that the child process did not exit normally, the value returned by the WEXITSTATUS macro has no meaning.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice