added missing m_closefrom.c
This commit is contained in:
parent
c4ea2a195c
commit
a99a4b2a05
1 changed files with 23 additions and 0 deletions
23
lib/nbsd_libc/sys-minix/m_closefrom.c
Normal file
23
lib/nbsd_libc/sys-minix/m_closefrom.c
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
#include "namespace.h"
|
||||||
|
#include <lib.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
Loading…
Reference in a new issue