2011-08-03 12:51:28 +02:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
#include "namespace.h"
|
|
|
|
#include <lib.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
2012-03-25 20:25:53 +02:00
|
|
|
int closefrom(int fd)
|
2011-08-03 12:51:28 +02:00
|
|
|
{
|
2011-11-28 11:07:55 +01:00
|
|
|
int f, ok = 0, e = 0;
|
2011-08-03 12:51:28 +02:00
|
|
|
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;
|
|
|
|
}
|