home *** CD-ROM | disk | FTP | other *** search
-
- /*
- * CLOSE.C
- *
- * (c)Copyright 1990, Matthew Dillon, All Rights Reserved
- */
-
- #include <stdio.h>
- #include <fcntl.h>
- #include <ioctl.h>
- #include <errno.h>
-
- void
- __closeall()
- {
- short fd;
-
- for (fd = 0; fd < _IoFDLimit; ++fd)
- close(fd);
- }
-
- int
- close(fd)
- int fd;
- {
- _IOFDS *d;
- int r = -1;
-
- if (d = __getfh(fd)) {
- if (d->fd_Exec) { /* special */
- r = (*d->fd_Exec)(d->fd_Fh, IOC_CLOSE, NULL);
- } else {
- r = 0;
- if ((d->fd_Flags & O_NOCLOSE) == 0)
- Close(d->fd_Fh);
- }
- d->fd_Flags = 0;
- d->fd_Exec = NULL;
- d->fd_Fh = NULL;
- }
- return(r);
- }
-
-