linux-sysprog · intermediate · ~15 min
Model the fd-allocation rule.
The kernel hands out the lowest available fd number. Implement int lowest_free_fd(const int *open_fds, int n) returning the smallest non-negative integer not present in the array.
int lowest_free_fd(const int *open_fds, int n) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.