diff --git a/lib/nbsd_libc/sys-minix/m_closefrom.c b/lib/nbsd_libc/sys-minix/m_closefrom.c new file mode 100644 index 000000000..962e84a5b --- /dev/null +++ b/lib/nbsd_libc/sys-minix/m_closefrom.c @@ -0,0 +1,23 @@ +#include +#include "namespace.h" +#include +#include +#include + +PUBLIC int closefrom(int fd) +{ + int f, ok = 0, e; + for(f = fd; f < __MINIX_OPEN_MAX; f++) { + if(close(f) >= 0) + ok = 1; + else + e = errno; + } + + if(ok) + return 0; + + /* all failed - return last valid error */ + errno = e; + return -1; +}