1FDETACH(3P)                POSIX Programmer's Manual               FDETACH(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10
11

NAME

13       fdetach — detach a name from a STREAMS-based file descriptor (STREAMS)
14

SYNOPSIS

16       #include <stropts.h>
17
18       int fdetach(const char *path);
19

DESCRIPTION

21       The fdetach() function shall detach a STREAMS-based file from the  file
22       to  which  it  was  attached by a previous call to fattach().  The path
23       argument points to the pathname  of  the  attached  STREAMS  file.  The
24       process  shall have appropriate privileges or be the owner of the file.
25       A successful call to fdetach() shall cause all pathnames that named the
26       attached  STREAMS file to again name the file to which the STREAMS file
27       was attached. All subsequent operations on path shall  operate  on  the
28       underlying file and not on the STREAMS file.
29
30       All  open  file  descriptions  established  while  the STREAMS file was
31       attached to the file referenced  by  path  shall  still  refer  to  the
32       STREAMS file after the fdetach() has taken effect.
33
34       If  there  are  no  open  file  descriptors  or other references to the
35       STREAMS file, then a successful call to fdetach() shall  be  equivalent
36       to performing the last close() on the attached file.
37

RETURN VALUE

39       Upon  successful  completion,  fdetach()  shall return 0; otherwise, it
40       shall return −1 and set errno to indicate the error.
41

ERRORS

43       The fdetach() function shall fail if:
44
45       EACCES Search permission is denied on a component of the path prefix.
46
47       EINVAL The path argument names a file that is not currently attached.
48
49       ELOOP  A loop exists in symbolic links encountered during resolution of
50              the path argument.
51
52       ENAMETOOLONG
53              The  length  of  a  component  of  a  pathname  is  longer  than
54              {NAME_MAX}.
55
56       ENOENT A component of path does not name an existing file or path is an
57              empty string.
58
59       ENOTDIR
60              A  component  of  the path prefix names an existing file that is
61              neither a directory nor a symbolic link to a directory,  or  the
62              path  argument  contains  at least one non-<slash> character and
63              ends with one or more trailing <slash> characters and  the  last
64              pathname  component  names  an  existing  file that is neither a
65              directory nor a symbolic link to a directory.
66
67       EPERM  The effective user ID is not the owner of path and  the  process
68              does not have appropriate privileges.
69
70       The fdetach() function may fail if:
71
72       ELOOP  More  than  {SYMLOOP_MAX} symbolic links were encountered during
73              resolution of the path argument.
74
75       ENAMETOOLONG
76              The length of a pathname exceeds {PATH_MAX}, or pathname resolu‐
77              tion  of  a symbolic link produced an intermediate result with a
78              length that exceeds {PATH_MAX}.
79
80       The following sections are informative.
81

EXAMPLES

83   Detaching a File
84       The following example detaches the STREAMS-based file /tmp/named-STREAM
85       from  the  file to which it was attached by a previous, successful call
86       to fattach().  Subsequent calls to open this file refer to the underly‐
87       ing file, not to the STREAMS file.
88
89           #include <stropts.h>
90           ...
91               char *pathname = "/tmp/named-STREAM";
92               int ret;
93
94               ret = fdetach(pathname);
95

APPLICATION USAGE

97       None.
98

RATIONALE

100       None.
101

FUTURE DIRECTIONS

103       The fdetach() function may be removed in a future version.
104

SEE ALSO

106       fattach()
107
108       The Base Definitions volume of POSIX.1‐2008, <stropts.h>
109
111       Portions  of  this text are reprinted and reproduced in electronic form
112       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
113       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
114       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
115       cal  and  Electronics  Engineers,  Inc  and  The  Open Group.  (This is
116       POSIX.1-2008 with the 2013 Technical Corrigendum  1  applied.)  In  the
117       event of any discrepancy between this version and the original IEEE and
118       The Open Group Standard, the original IEEE and The Open Group  Standard
119       is  the  referee document. The original Standard can be obtained online
120       at http://www.unix.org/online.html .
121
122       Any typographical or formatting errors that appear  in  this  page  are
123       most likely to have been introduced during the conversion of the source
124       files to man page format. To report such errors,  see  https://www.ker
125       nel.org/doc/man-pages/reporting_bugs.html .
126
127
128
129IEEE/The Open Group                  2013                          FDETACH(3P)
Impressum