.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved .TH "FDETACH" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" .\" fdetach .SH NAME fdetach \- detach a name from a STREAMS-based file descriptor (\fBSTREAMS\fP) .SH SYNOPSIS .LP \fB#include .br .sp int fdetach(const char *\fP\fIpath\fP\fB); \fP \fB .br \fP .SH DESCRIPTION .LP The \fIfdetach\fP() function shall detach a STREAMS-based file from the file to which it was attached by a previous call to \fIfattach\fP(). The \fIpath\fP argument points to the pathname of the attached STREAMS file. The process shall have appropriate privileges or be the owner of the file. A successful call to \fIfdetach\fP() shall cause all pathnames that named the attached STREAMS file to again name the file to which the STREAMS file was attached. All subsequent operations on \fIpath\fP shall operate on the underlying file and not on the STREAMS file. .LP All open file descriptions established while the STREAMS file was attached to the file referenced by \fIpath\fP shall still refer to the STREAMS file after the \fIfdetach\fP() has taken effect. .LP If there are no open file descriptors or other references to the STREAMS file, then a successful call to \fIfdetach\fP() shall be equivalent to performing the last \fIclose\fP() on the attached file. .SH RETURN VALUE .LP Upon successful completion, \fIfdetach\fP() shall return 0; otherwise, it shall return -1 and set \fIerrno\fP to indicate the error. .SH ERRORS .LP The \fIfdetach\fP() function shall fail if: .TP 7 .B EACCES Search permission is denied on a component of the path prefix. .TP 7 .B EINVAL The \fIpath\fP argument names a file that is not currently attached. .TP 7 .B ELOOP A loop exists in symbolic links encountered during resolution of the \fIpath\fP argument. .TP 7 .B ENAMETOOLONG The size of a pathname exceeds {PATH_MAX} or a pathname component is longer than {NAME_MAX}. .TP 7 .B ENOENT A component of \fIpath\fP does not name an existing file or \fIpath\fP is an empty string. .TP 7 .B ENOTDIR A component of the path prefix is not a directory. .TP 7 .B EPERM The effective user ID is not the owner of \fIpath\fP and the process does not have appropriate privileges. .sp .LP The \fIfdetach\fP() function may fail if: .TP 7 .B ELOOP More than {SYMLOOP_MAX} symbolic links were encountered during resolution of the \fIpath\fP argument. .TP 7 .B ENAMETOOLONG Pathname resolution of a symbolic link produced an intermediate result whose length exceeds {PATH_MAX}. .sp .LP \fIThe following sections are informative.\fP .SH EXAMPLES .SS Detaching a File .LP The following example detaches the STREAMS-based file \fB/tmp/named-STREAM\fP from the file to which it was attached by a previous, successful call to \fIfattach\fP(). Subsequent calls to open this file refer to the underlying file, not to the STREAMS file. .sp .RS .nf \fB#include \&... char *filename = "/tmp/named-STREAM"; int ret; .sp ret = fdetach(filename); \fP .fi .RE .SH APPLICATION USAGE .LP None. .SH RATIONALE .LP None. .SH FUTURE DIRECTIONS .LP None. .SH SEE ALSO .LP \fIfattach\fP() , the Base Definitions volume of IEEE\ Std\ 1003.1-2001, \fI\fP .SH COPYRIGHT Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .