repo.or.cz
/
minix.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
etc/services - sync with NetBSD-8
[minix.git]
/
minix
/
lib
/
libc
/
sys
/
m_closefrom.c
blob
14db9f80fcbfd9e905b7fe2dcf66cbc779058873
1
#include <sys/cdefs.h>
2
#include
"namespace.h"
3
#include <lib.h>
4
#include <stdlib.h>
5
#include <unistd.h>
6
7
int
closefrom
(
int
fd
)
8
{
9
int
f
,
ok
=
0
,
e
=
0
;
10
for
(
f
=
fd
;
f
<
OPEN_MAX
;
f
++) {
11
if
(
close
(
f
) >=
0
)
12
ok
=
1
;
13
else
14
e
=
errno
;
15
}
16
17
if
(
ok
)
18
return
0
;
19
20
/* all failed - return last valid error */
21
errno
=
e
;
22
return
-
1
;
23
}