const errno = system.getErrno;

To obtain errno, call this function with the return value of the system function call. For some systems this will obtain the value directly from the return code; for others it will use a thread-local errno variable. Therefore, this function only returns a well-defined value when it is called directly after the system function call which one wants to learn the errno value of.