If what I am trying to do is not a good idea or not supported, please feel free to let me know. I am trying to use various system libraries (libc.so.6
, libpthread.so.0
, etc.) for an API. The API will be calling into these libraries to access open()
, close()
, etc...
I'm not sure how to handle errno
on failures, returning -1, rather than returning errno
directly. When I make a call to close()
in libc.so.6
, it returns -1 on failure, so I can detect an error occurred. However, I cannot seem to find any mechanism in libc that allows me to query the current value of errno
that may have been set by a previous function call in the same thread. This isn't a problem when calling pthread
functions because they return errno
's value directly, and I can work with this.
Is there a way to determine the current value of errno
for a given thread following the execution of a function that would have set errno
(such as close()
) using a library call of some kind?
Possible solutions:
I could write a wrapper library that calls close()
, etc... queries errno
in an error state, and returns errno
directly, but I'm trying to avoid having to include custom libraries that would have to be included with the API.
If there is a way to call a standard library, that would be ideal.