Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ close(2) — posix — mips UMIPS RISC/os 4.52

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

creat(2)

dup(2)

exec(2)

fcntl(2)

intro(2)

open(2)

pipe(2)

signal(2)

sigaction(2)

streamio(7)



CLOSE(2-POSIX)      RISC/os Reference Manual       CLOSE(2-POSIX)



NAME
     close - close a file descriptor

SYNOPSIS
     int close (fildes)
     int fildes;

DESCRIPTION
     fildes is a file descriptor obtained from a creat, open,
     dup, dup2, fcntl, or pipe system call.  close closes the
     file descriptor indicated by fildes.  All outstanding record
     locks owned by the process (on the file indicated by fildes)
     are removed.

     If close is interrupted by a signal that is to be caught, it
     returns -1 and errno is set to EINTR and the state of fildes
     is unspecified.

     When all file descriptors associated with a pipe of FIFO
     special file have been closed, any data remaining in the
     pipe or FIFO is discarded.

     When all file descriptors associated with an open file
     description have been closed, the open file description is
     freed.

     If the link count of the file is zero, when all file
     descriptors associated with the file have been closed, the
     space occupied by the file is freed and the file is no
     longer accessible.

     If a STREAMS [see intro(2)] file is closed, and the calling
     process had previously registered to receive a SIGPOLL sig-
     nal [see signal(2) and sigaction(2)] for events associated
     with that file [see I_SETSIG in streamio(7)], the calling
     process will be unregistered for events associated with the
     file.  The last close for a stream causes the stream associ-
     ated with fildes to be dismantled.  If O_NONBLOCK is not set
     and there have been no signals posted for the stream, close
     waits up to 20 seconds, for each module and driver, for any
     output to drain before dismantling the stream.  If the
     O_NONBLOCK flag is set or if there are any pending signals,
     close does not wait for output to drain, and dismantles the
     stream immediately.

ERRORS
     The named file is closed unless one or more of the following
     are true:

     [EBADF]             fildes is not a valid open file descrip-
                         tor.




                         Printed 1/15/91                   Page 1





CLOSE(2-POSIX)      RISC/os Reference Manual       CLOSE(2-POSIX)



     [EINTR]             A signal was caught during the close
                         system call.

     [ETIME]             The timer went off waiting for output to
                         drain.

SEE ALSO
     creat(2), dup(2), exec(2), fcntl(2), intro(2), open(2),
     pipe(2), signal(2), sigaction(2).
     streamio(7) in the System Administrator's Reference Manual.

DIAGNOSTICS
     Upon successful completion, a value of 0 is returned.  Oth-
     erwise, a value of -1 is returned and errno is set to indi-
     cate the error.








































 Page 2                  Printed 1/15/91



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026