Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I use use ip by system("ip link set eth0 up") in a C program. I know that system returns -1 if it fails and returns what the called function returns(exit). E.g., if eth0 is not exist on the system, it returns 256. Where can I find what these numerical values defined for ip?

For example ifconfig's Return Codes:

Return Code Description
0    The command completed successfully.
4    The command completed successfully, but a warning condition was detected.
8    The command was not specified correctly.
12    An error was encountered.
16    An unexpected condition was encountered.
share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

You'll find the return values in the documentation. Failing that, look at the source code.

I think ip doesn't do anything fancier than return 0 for success and 255 for failure.

Make sure you've read the documentation of the system function properly. Your description is wrong: system only returns -1 if it fails to start the external program, otherwise it returns a value that encodes the process's return code and other information. 256 means that the process returned 1.

share|improve this answer
    
thank you for the correction and the explanation –  sven Jun 11 '13 at 0:38
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.