⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 close.2

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 2
字号:
.\" SCCSID: @(#)close.2	8.1	9/11/90.TH close 2.SH Nameclose \- delete a descriptor.SH Syntax.B close(\fIfd\fP).br.B "int \fIfd\fP;".SH Description.NXR "close system call".NXA "close system call" "open system call".NXA "file descriptor" "process reference table".NXR "file descriptor" "deleting"The.PN closecall deletes a descriptor from the per-process objectreference table.If the descriptor is the last reference to the underlying object, thenthe object is deactivated.  For example, on the last closeof a file, the current .PN seekpointer associated with the file is lost.On the last close of a socket,.PN closediscards associated naming information and queued data. On the last close of a file holding an advisory lock, the lock is released. For further information, see.MS flock 2 ..PPA process's descriptors are automatically closed when a process exits, but because each process can have a limited number of activedescriptors,.PN closeis necessary for programs that deal with many descriptors..PPWhen a process forks, all descriptors for the new child processreference the same objects as they did in the parent process before the fork.For further information, see .MS fork 2 .If a new process is then to be run using .PN execve ,the process would normally inherit these descriptors.  Mostof the descriptors can be rearranged with the.PN dup2 system call or deleted with.PN closebefore .PN execveis called. However, if any descriptors areneeded if the .PN execvefails, they must be closed if the execve succeeds.For this reason, the call, fcntl(d, F_SETFD, 1), is provided. This callarranges that a descriptor is closed after a successful.PN execvecall.The call, fcntl(d, F_SETFD, 0), restores the default,which is to not close the descriptor..PPWhen .PN closeis used on a descriptor that refers to aremote file over NFS, and that file has been modified byusing .MS write 2 , then any cached .PN writedata is flushedbefore .PN closereturns. If an asynchronouswrite error has occurred previously with this remote file, oroccurred as part of the flush operation described above,then .PN close returns \-1 and errno will be set to theerror code. The return code from .MS close 2 should be inspectedby any program that can .PN writeover NFS..SH Return ValuesUpon successful completion, a value of 0 is returned.Otherwise, a value of \-1 is returned, and the global integer variable,.I errno,is set to indicate the error.  .SH DiagnosticsThe.PN closesystem call fails under the following conditions:.TP 15[EBADF]\fID\fP is not an active descriptor.  .TP 15[EINTR]The.PN closefunction was interrupted by a signal..PPIf an error occurs on anasynchronous write over NFS, the error cannot always be returned from a.PN writesystem call.  The error code is returned on.PN closeor.PN fsync . The following are NFS-only error messages:.TP 15[EACCESS]The requested address is protected, and the current userhas inadequate permission to access it..TP 15[ENOSPC]There is no free space remaining on the file system containingthe file..TP 15[EDQUOT]The user's quota of disk blocks on the file system containingthe file has been exhausted..TP 15[EIO]An I/O error occurred while reading from or writing to the filesystem..TP 15[EROFS]The file is on a read-only file system..TP 15[ESTALE]The.I fdargument is invalid because the file referredto by that file handle no longer exists or has been revoked..TP[ETIMEDOUT]A write operation failedbecause the serverdid not properly respond after a periodof time that is dependent on the.MS mount 8nfsoptions..SH See Alsoaccept(2), execve(2), fcntl(2), flock(2), fsync(2),open(2), pipe(2), socket(2), socketpair(2), write(2)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -