2 .\" Copyright (c) 2002 The FreeBSD Project, Inc.
3 .\" All rights reserved.
5 .\" This software includes code contributed to the FreeBSD Project
6 .\" by Ryan Younce of North Carolina State University.
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
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.
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.
34 .Dd September 10, 2009
39 .Nd "open a pseudo-terminal device"
46 .Fn posix_openpt "int oflag"
50 function allocates a new pseudo-terminal and establishes a connection
51 with its master device.
52 A slave device shall be created in
54 After the pseudo-terminal has been allocated, the slave will already
55 have the proper permissions (see
57 without the need to call
59 The name of the slave device can be determined by calling
62 The file status flags and file access modes of the open file description
63 shall be set according to the value of
67 are constructed by a bitwise-inclusive OR of flags from the following
70 .Bl -tag -width ".Dv O_NOCTTY"
72 Open for reading and writing.
76 shall not cause the terminal device to become the controlling terminal
82 function shall fail when
84 contains other values.
86 Upon successful completion, the
88 function shall allocate a new pseudo-terminal device and return a
89 non-negative integer representing a file descriptor, which is connected
91 Otherwise, -1 shall be returned and errno set to indicate the error.
95 function shall fail if:
98 The system file table is full.
111 The standards committee did not want to directly expose the cloning device and
112 thus decided to wrap the functionality in this function.
113 The equivalent code would be:
116 posix_openpt(int oflag) {
117 return open("/dev/ptmx", oflag);
142 is included for compatibility; in
144 opening a terminal does not cause it to become a process's controlling