linux-sysprog · intermediate · ~15 min
Read errno after a failed syscall.
Implement int missing_file_errno(void) that tries to open a file that does not exist (O_RDONLY) and returns the resulting errno value.
#include <fcntl.h>
#include <errno.h>
int missing_file_errno(void) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.