Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   system commad (http://www.go4expert.com/forums/system-commad-t1195/)

sharathg_535 14Aug2006 10:40

system commad
 
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

shabbir 14Aug2006 12:06

Re: system commad
 
Use WEXITSTATUS to get the status.

sharathg_535 14Aug2006 12:09

Re: system commad
 
Could you please explain what is WEXITSTATUS ...

shabbir 14Aug2006 12:27

Re: system commad
 
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.


All times are GMT +5.5. The time now is 22:03.