Commit | Line | Data |
---|---|---|
a8d10b60 KB |
1 | /*- |
2 | * Copyright (c) 1982, 1988 The Regents of the University of California. | |
3 | * All rights reserved. | |
4 | * | |
5 | * %sccs.include.proprietary.c% | |
6 | * | |
38a01dbe | 7 | * @(#)close.c 7.2 (Berkeley) %G% |
a8d10b60 KB |
8 | */ |
9 | ||
10 | #include <sys/param.h> | |
38a01dbe | 11 | #include <stand/saio.h> |
a8d10b60 KB |
12 | |
13 | close(fdesc) | |
14 | int fdesc; | |
15 | { | |
16 | #ifndef SMALL | |
17 | struct iob *file; | |
18 | ||
19 | fdesc -= 3; | |
20 | if (fdesc < 0 || fdesc >= SOPEN_MAX || | |
21 | ((file = &iob[fdesc])->i_flgs&F_ALLOC) == 0) { | |
22 | errno = EBADF; | |
23 | return (-1); | |
24 | } | |
25 | if ((file->i_flgs&F_FILE) == 0) | |
26 | devclose(file); | |
27 | file->i_flgs = 0; | |
28 | #endif | |
29 | return (0); | |
30 | } |