]>
Commit | Line | Data |
---|---|---|
4710caba MK |
1 | .\" Copyright (C) 2004 Michael Kerrisk |
2 | .\" | |
93015253 | 3 | .\" %%%LICENSE_START(VERBATIM) |
4710caba MK |
4 | .\" Permission is granted to make and distribute verbatim copies of this |
5 | .\" manual provided the copyright notice and this permission notice are | |
6 | .\" preserved on all copies. | |
7 | .\" | |
8 | .\" Permission is granted to copy and distribute modified versions of this | |
9 | .\" manual under the conditions for verbatim copying, provided that the | |
10 | .\" entire resulting derived work is distributed under the terms of a | |
11 | .\" permission notice identical to this one. | |
c13182ef | 12 | .\" |
4710caba MK |
13 | .\" Since the Linux kernel and libraries are constantly changing, this |
14 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
15 | .\" responsibility for errors or omissions, or for damages resulting from | |
16 | .\" the use of the information contained herein. The author(s) may not | |
17 | .\" have taken the same level of care in the production of this manual, | |
18 | .\" which is licensed free of charge, as they might when working | |
19 | .\" professionally. | |
c13182ef | 20 | .\" |
4710caba MK |
21 | .\" Formatted or processed versions of this manual, if unaccompanied by |
22 | .\" the source, must acknowledge the copyright and authors of this work. | |
4b72fb64 | 23 | .\" %%%LICENSE_END |
4710caba | 24 | .\" |
4b8c67d9 | 25 | .TH POSIX_OPENPT 3 2017-09-15 "" "Linux Programmer's Manual" |
4710caba | 26 | .SH NAME |
b218b023 | 27 | posix_openpt \- open a pseudoterminal device |
4710caba MK |
28 | .SH SYNOPSIS |
29 | .nf | |
4710caba MK |
30 | .B #include <stdlib.h> |
31 | .B #include <fcntl.h> | |
68e4db0a | 32 | .PP |
92e6a919 | 33 | .BI "int posix_openpt(int " flags ");" |
4710caba | 34 | .fi |
68e4db0a | 35 | .PP |
cc4615cc MK |
36 | .in -4n |
37 | Feature Test Macro Requirements for glibc (see | |
38 | .BR feature_test_macros (7)): | |
39 | .in | |
68e4db0a | 40 | .PP |
cc4615cc MK |
41 | .ad l |
42 | .BR posix_openpt (): | |
48d8c37d | 43 | _XOPEN_SOURCE\ >=\ 600 |
cc4615cc | 44 | .ad b |
4710caba MK |
45 | .SH DESCRIPTION |
46 | The | |
47 | .BR posix_openpt () | |
b218b023 | 48 | function opens an unused pseudoterminal master device, returning a |
4710caba | 49 | file descriptor that can be used to refer to that device. |
847e0d88 | 50 | .PP |
4710caba MK |
51 | The |
52 | .I flags | |
53 | argument is a bit mask that ORs together zero or more of | |
54 | the following flags: | |
55 | .TP | |
704a18f0 | 56 | .B O_RDWR |
4710caba MK |
57 | Open the device for both reading and writing. |
58 | It is usual to specify this flag. | |
59 | .TP | |
60 | .B O_NOCTTY | |
61 | Do not make this device the controlling terminal for the process. | |
47297adb | 62 | .SH RETURN VALUE |
4710caba | 63 | On success, |
104b099e | 64 | .BR posix_openpt () |
2fda57bd | 65 | returns a nonnegative file descriptor which is the lowest |
d9cb0d7d | 66 | numbered unused file descriptor. |
8729177b | 67 | On failure, \-1 is returned, and |
4710caba MK |
68 | .I errno |
69 | is set to indicate the error. | |
70 | .SH ERRORS | |
71 | See | |
72 | .BR open (2). | |
ee332a95 MK |
73 | .SH VERSIONS |
74 | Glibc support for | |
75 | .BR posix_openpt () | |
76 | has been provided since version 2.2.1. | |
ebd03e29 | 77 | .SH ATTRIBUTES |
9b940a23 PH |
78 | For an explanation of the terms used in this section, see |
79 | .BR attributes (7). | |
80 | .TS | |
81 | allbox; | |
82 | lb lb lb | |
83 | l l l. | |
84 | Interface Attribute Value | |
85 | T{ | |
ebd03e29 | 86 | .BR posix_openpt () |
9b940a23 PH |
87 | T} Thread safety MT-Safe |
88 | .TE | |
47297adb | 89 | .SH CONFORMING TO |
a9fb6f01 | 90 | POSIX.1-2001, POSIX.1-2008. |
847e0d88 | 91 | .PP |
4710caba | 92 | .BR posix_openpt () |
b218b023 | 93 | is part of the UNIX 98 pseudoterminal support (see |
4710caba | 94 | .BR pts (4)). |
4710caba | 95 | .SH NOTES |
ebc28d13 | 96 | Some older UNIX implementations that support System V |
b218b023 | 97 | (aka UNIX 98) pseudoterminals don't have this function, but it |
4710caba | 98 | is easy to implement: |
e646a1ba | 99 | .PP |
a08ea57c | 100 | .in +4n |
e646a1ba | 101 | .EX |
4710caba MK |
102 | int |
103 | posix_openpt(int flags) | |
104 | { | |
105 | return open("/dev/ptmx", flags); | |
106 | } | |
b8302363 | 107 | .EE |
a08ea57c | 108 | .in |
66dd9100 MK |
109 | .PP |
110 | Calling | |
111 | .BR posix_openpt () | |
112 | creates a pathname for the corresponding pseudoterminal slave device. | |
113 | The pathname of the slave device can be obtained using | |
114 | .BR ptsname (3). | |
115 | The slave device pathname exists only as long as the master device is open. | |
47297adb | 116 | .SH SEE ALSO |
4710caba MK |
117 | .BR open (2), |
118 | .BR getpt (3), | |
119 | .BR grantpt (3), | |
120 | .BR ptsname (3), | |
b336ac27 | 121 | .BR unlockpt (3), |
88ab292b MK |
122 | .BR pts (4), |
123 | .BR pty (7) |