summaryrefslogtreecommitdiff
path: root/static/netbsd/man4/fd.4 4.html
blob: e5b94b7fc7ff35b2b5c40a86566b6a817435b6ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<table class="head">
  <tr>
    <td class="head-ltitle">FD(4)</td>
    <td class="head-vol">Device Drivers Manual</td>
    <td class="head-rtitle">FD(4)</td>
  </tr>
</table>
<div class="manual-text">
<section class="Sh">
<h1 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1>
<p class="Pp"><code class="Nm">fd</code>, <code class="Nm">stdin</code>,
    <code class="Nm">stdout</code>, <code class="Nm">stderr</code> &#x2014;
    <span class="Nd">file descriptor files</span></p>
</section>
<section class="Sh">
<h1 class="Sh" id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">DESCRIPTION</a></h1>
<p class="Pp">The files <span class="Pa">/dev/fd/0</span> through
    <span class="Pa">/dev/fd/#</span> refer to file descriptors which can be
    accessed through the file system. If the file descriptor is open and the
    mode the file is being opened with is a subset of the mode of the existing
    descriptor, the call:</p>
<div class="Bd Pp Bd-indent Li">
<pre>fd = open(&quot;/dev/fd/0&quot;, mode);</pre>
</div>
<p class="Pp">and the call:</p>
<div class="Bd Pp Bd-indent Li">
<pre>fd = fcntl(0, F_DUPFD, 0);</pre>
</div>
<p class="Pp">are equivalent.</p>
<p class="Pp">Opening the files <span class="Pa">/dev/stdin</span>,
    <span class="Pa">/dev/stdout</span> and <span class="Pa">/dev/stderr</span>
    is equivalent to the following calls:</p>
<div class="Bd Pp Bd-indent Li">
<pre>fd = fcntl(STDIN_FILENO,  F_DUPFD, 0);
fd = fcntl(STDOUT_FILENO, F_DUPFD, 0);
fd = fcntl(STDERR_FILENO, F_DUPFD, 0);</pre>
</div>
<p class="Pp">Flags to the <a class="Xr">open(2)</a> call other than
    <code class="Dv">O_RDONLY</code>, <code class="Dv">O_WRONLY</code> and
    <code class="Dv">O_RDWR</code> are ignored.</p>
</section>
<section class="Sh">
<h1 class="Sh" id="FILES"><a class="permalink" href="#FILES">FILES</a></h1>
<dl class="Bl-tag Bl-compact">
  <dt><span class="Pa">/dev/fd/#</span></dt>
  <dd style="width: auto;">&#x00A0;</dd>
  <dt><span class="Pa">/dev/stdin</span></dt>
  <dd style="width: auto;">&#x00A0;</dd>
  <dt><span class="Pa">/dev/stdout</span></dt>
  <dd style="width: auto;">&#x00A0;</dd>
  <dt><span class="Pa">/dev/stderr</span></dt>
  <dd style="width: auto;">&#x00A0;</dd>
</dl>
</section>
<section class="Sh">
<h1 class="Sh" id="SEE_ALSO"><a class="permalink" href="#SEE_ALSO">SEE
  ALSO</a></h1>
<p class="Pp"><a class="Xr">tty(4)</a>, <a class="Xr">mount_fdesc(8)</a></p>
<section class="Ss">
<h2 class="Ss" id="NOTE"><a class="permalink" href="#NOTE">NOTE</a></h2>
<p class="Pp">The floppy disk driver on some ports is also called
    <code class="Nm">fd</code>; see <a class="Xr">fdc(4)</a> for its
    documentation.</p>
</section>
</section>
</div>
<table class="foot">
  <tr>
    <td class="foot-date">December 29, 2013</td>
    <td class="foot-os">NetBSD 10.1</td>
  </tr>
</table>