: >Does the 'errno' variable belong to a process or to the unix kernel ?
: It is a per-process variable, set by library calls. it is defined in
: libc.a
A small correction: On modern OSs, errno is a thread level concept(note,
I don't say "variable"). In solaris, for example, errno is not a variable -
it is #define'd to a function call (*(___errno())) .
Of course, it still is a user-level thingie.
:
: >it a good thing for an "in-house" library subroutine to set errno or is
: >it not recommended (and why) ?
:
: If you know what you're doing :^) !.. some subsequent system call,
: hidden inside library functions, may modify errno.
: You can safely use the values defined in <sys/errno.h> like EPERM,
: ENOENT, ... to indicate error by return value.
If there's any chance this system is going to use threads in the future,
you can't do this.
If not, there are still two ways to understand this question ...
When setting errno, do you propose to use existing values defined in
errno.h, or introduce your own values ?
The former is ok, but I'd be hesitant to use the latter, because a couple
of years from now that value may be used for some wholly unrelated purpose
by the OS vendor.
-Sriram