-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Linux System Programming Techniques
By :
Even though human-readable error messages are important, we must not forget to return a value to the shell that indicates an error. We have already seen that returning 0 means that everything is okay, while returning something else (most of the time, 1) means that some kind of error did occur. However, we can return more specific values if we want so that other programs relying on our program can read those numbers. For example, we can actually return the errno variable since it is just an integer. All the macros we have seen, such as EACCES and ENOENT, are integers (13 and 2 for EACCES and ENOENT, respectively).
In this recipe, we will learn how to return the errno numbers to the shell to provide more specific information.
The same set of programs mentioned in the previous recipe apply to this recipe.
In this recipe, we will make the seventh version of our simple-touch program. Let's get started: