How does strace get errno from failed system calls in the process it traces?
For example, if I do strace ls, strace displays the symbolic errno value (e.g. ENOENT) when a call fails. I know that strace uses ptrace under the hood.
If I am using ptrace to trace a processes system calls, how can I read the value of errno in the traced process?
More specifically, how do I get the address of errno in the child process, so that I can read it using PTRACE_PEEKDATA or process_vm_readv?
Thanks