gdb - Local mods (compile)
[dragonfly.git] / lib / libc / stdlib / posix_openpt.3
CommitLineData
a85b8d87
AH
1.\"
2.\" Copyright (c) 2002 The FreeBSD Project, Inc.
3.\" All rights reserved.
4.\"
5.\" This software includes code contributed to the FreeBSD Project
6.\" by Ryan Younce of North Carolina State University.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
16.\" 3. Neither the name of the FreeBSD Project nor the names of its
17.\" contributors may be used to endorse or promote products derived from
18.\" this software without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE FREEBSD PROJECT AND CONTRIBUTORS
21.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23.\" PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FREEBSD PROJECT
24.\" OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
26.\" TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27.\" PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28.\" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29.\" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30.\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31.\"
fb5b3747 32.\" $FreeBSD: src/lib/libc/sys/posix_openpt.2,v 1.1 2008/08/20 08:31:58 ed Exp $
a85b8d87
AH
33.\"
34.Dd September 10, 2009
a85b8d87 35.Dt POSIX_OPENPT 3
fb5b3747 36.Os
a85b8d87
AH
37.Sh NAME
38.Nm posix_openpt
39.Nd "open a pseudo-terminal device"
40.Sh LIBRARY
41.Lb libc
42.Sh SYNOPSIS
43.In stdlib.h
44.In fcntl.h
45.Ft int
46.Fn posix_openpt "int oflag"
47.Sh DESCRIPTION
48The
49.Fn posix_openpt
50function allocates a new pseudo-terminal and establishes a connection
51with its master device.
52A slave device shall be created in
53.Pa /dev/pts .
54After the pseudo-terminal has been allocated, the slave will already
55have the proper permissions (see
56.Xr grantpt 3 )
57without the need to call
58.Xr grantpt 3 .
59The name of the slave device can be determined by calling
60.Xr ptsname 3 .
61.Pp
62The file status flags and file access modes of the open file description
63shall be set according to the value of
64.Fa oflag .
65Values for
66.Fa oflag
67are constructed by a bitwise-inclusive OR of flags from the following
68list, defined in
69.In fcntl.h :
70.Bl -tag -width ".Dv O_NOCTTY"
71.It Dv O_RDWR
72Open for reading and writing.
73.It Dv O_NOCTTY
74If set
75.Fn posix_openpt
76shall not cause the terminal device to become the controlling terminal
77for the process.
78.El
79.Pp
80The
81.Fn posix_openpt
82function shall fail when
83.Fa oflag
84contains other values.
85.Sh RETURN VALUES
86Upon successful completion, the
87.Fn posix_openpt
88function shall allocate a new pseudo-terminal device and return a
89non-negative integer representing a file descriptor, which is connected
90to its master device.
91Otherwise, -1 shall be returned and errno set to indicate the error.
92.Sh ERRORS
93The
94.Fn posix_openpt
95function shall fail if:
96.Bl -tag -width Er
97.It Bq Er ENFILE
98The system file table is full.
99.It Bq Er EINVAL
100The value of
101.Fa oflag
102is not valid.
103.El
104.Sh SEE ALSO
105.Xr open 2 ,
106.Xr grantpt 3 ,
107.Xr ptsname 3 ,
108.Xr unlockpt 3 ,
109.Xr tty 4
110.Sh RATIONALE
111The standards committee did not want to directly expose the cloning device and
112thus decided to wrap the functionality in this function.
113The equivalent code would be:
114.Bd -literal
115 int
116 posix_openpt(int oflag) {
117 return open("/dev/ptmx", oflag);
118 }
119.Ed
120.Sh STANDARDS
121The
122.Fn posix_openpt
123function conforms to
124.St -p1003.1-2001 .
125.Sh HISTORY
126The
127.Fn posix_openpt
128function appeared in
129.Dx 2.3 .
130.Sh NOTES
131The
132.Fn posix_openpt
133is equivalent in
134.Dx
135to calling
136.Xr open 2
137on
138.Pa /dev/ptmx .
139.Pp
140The flag
141.Dv O_NOCTTY
142is included for compatibility; in
143.Dx ,
144opening a terminal does not cause it to become a process's controlling
145terminal.