Search code examples
csystem-callsstaterrno

How to access errno after using syscall?


I'm using syscall stat, it returns 0/-1. When -1 is returned it means, error occurred and errno is set as it should be (source: man 2 stat).

But I want to access errno and print it, how to do that?


Solution

  • You can get it from errno.

    Also you can print the error using strerror