]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - lib/libc/sys/posix_openpt.2
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / lib / libc / sys / posix_openpt.2
1 .\" Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org>
2 .\" All rights reserved.
3 .\"
4 .\" Portions of this software were developed under sponsorship from Snow
5 .\" B.V., the Netherlands.
6 .\"
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
9 .\" are met:
10 .\" 1. Redistributions of source code must retain the above copyright
11 .\"    notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\"    notice, this list of conditions and the following disclaimer in the
14 .\"    documentation and/or other materials provided with the distribution.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 .\" SUCH DAMAGE.
27 .\"
28 .\" Portions of this text are reprinted and reproduced in electronic form
29 .\" from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology --
30 .\" Portable Operating System Interface (POSIX), The Open Group Base
31 .\" Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of
32 .\" Electrical and Electronics Engineers, Inc and The Open Group.  In the
33 .\" event of any discrepancy between this version and the original IEEE and
34 .\" The Open Group Standard, the original IEEE and The Open Group Standard is
35 .\" the referee document.  The original Standard can be obtained online at
36 .\"     http://www.opengroup.org/unix/online.html.
37 .\"
38 .\" $FreeBSD$
39 .\"
40 .Dd March 21, 2013
41 .Dt POSIX_OPENPT 2
42 .Os
43 .Sh NAME
44 .Nm posix_openpt
45 .Nd "open a pseudo-terminal device"
46 .Sh LIBRARY
47 .Lb libc
48 .Sh SYNOPSIS
49 .In stdlib.h
50 .In fcntl.h
51 .Ft int
52 .Fn posix_openpt "int oflag"
53 .Sh DESCRIPTION
54 The
55 .Fn posix_openpt
56 function allocates a new pseudo-terminal and establishes a connection
57 with its master device.
58 A slave device shall be created in
59 .Pa /dev/pts .
60 After the pseudo-terminal has been allocated, the slave device should
61 have the proper permissions before it can be used (see
62 .Xr grantpt 3 ) .
63 The name of the slave device can be determined by calling
64 .Xr ptsname 3 .
65 .Pp
66 The file status flags and file access modes of the open file description
67 shall be set according to the value of
68 .Fa oflag .
69 Values for
70 .Fa oflag
71 are constructed by a bitwise-inclusive OR of flags from the following
72 list, defined in
73 .In fcntl.h :
74 .Bl -tag -width ".Dv O_CLOEXEC"
75 .It Dv O_RDWR
76 Open for reading and writing.
77 .It Dv O_NOCTTY
78 If set
79 .Fn posix_openpt
80 shall not cause the terminal device to become the controlling terminal
81 for the process.
82 .It Dv O_CLOEXEC
83 Set the close-on-exec flag for the new file descriptor.
84 .El
85 .Pp
86 The
87 .Fn posix_openpt
88 function shall fail when
89 .Fa oflag
90 contains other values.
91 .Sh RETURN VALUES
92 Upon successful completion, the
93 .Fn posix_openpt
94 function shall allocate a new pseudo-terminal device and return a
95 non-negative integer representing a file descriptor, which is connected
96 to its master device.
97 Otherwise, -1 shall be returned and errno set to indicate the error.
98 .Sh ERRORS
99 The
100 .Fn posix_openpt
101 function shall fail if:
102 .Bl -tag -width Er
103 .It Bq Er ENFILE
104 The system file table is full.
105 .It Bq Er EINVAL
106 The value of
107 .Fa oflag
108 is not valid.
109 .It Bq Er EAGAIN
110 Out of pseudo-terminal resources.
111 .El
112 .Sh SEE ALSO
113 .Xr pts 4 ,
114 .Xr ptsname 3 ,
115 .Xr tty 4
116 .Sh STANDARDS
117 The
118 .Fn posix_openpt
119 function conforms to
120 .St -p1003.1-2001 .
121 The ability to use
122 .Dv O_CLOEXEC
123 is an extension to the standard.
124 .Sh HISTORY
125 The
126 .Fn posix_openpt
127 function appeared in
128 .Fx 5.0 .
129 In
130 .Fx 8.0 ,
131 this function was changed to a system call.
132 .Sh NOTES
133 The flag
134 .Dv O_NOCTTY
135 is included for compatibility; in
136 .Fx ,
137 opening a terminal does not cause it to become a process's controlling
138 terminal.
139 .Sh AUTHORS
140 .An Ed Schouten Aq ed@FreeBSD.org