]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/posix_openpt.3
Many pages: Fix style issues reported by `make lint-groff`
[thirdparty/man-pages.git] / man3 / posix_openpt.3
CommitLineData
4710caba
MK
1.\" Copyright (C) 2004 Michael Kerrisk
2.\"
5fbde956 3.\" SPDX-License-Identifier: Linux-man-pages-copyleft
4710caba 4.\"
1ae6b2c7 5.TH POSIX_OPENPT 3 2021-03-22 GNU "Linux Programmer's Manual"
4710caba 6.SH NAME
b218b023 7posix_openpt \- open a pseudoterminal device
93a51597
AC
8.SH LIBRARY
9Standard C library
8fc3b2cf 10.RI ( libc ", " \-lc )
4710caba
MK
11.SH SYNOPSIS
12.nf
4710caba
MK
13.B #include <stdlib.h>
14.B #include <fcntl.h>
68e4db0a 15.PP
92e6a919 16.BI "int posix_openpt(int " flags ");"
4710caba 17.fi
68e4db0a 18.PP
d39ad78f 19.RS -4
cc4615cc
MK
20Feature Test Macro Requirements for glibc (see
21.BR feature_test_macros (7)):
d39ad78f 22.RE
68e4db0a 23.PP
cc4615cc 24.BR posix_openpt ():
9d2adbae 25.nf
5c10d2c5 26 _XOPEN_SOURCE >= 600
9d2adbae 27.fi
4710caba
MK
28.SH DESCRIPTION
29The
30.BR posix_openpt ()
b218b023 31function opens an unused pseudoterminal master device, returning a
4710caba 32file descriptor that can be used to refer to that device.
847e0d88 33.PP
4710caba
MK
34The
35.I flags
36argument is a bit mask that ORs together zero or more of
37the following flags:
38.TP
704a18f0 39.B O_RDWR
4710caba
MK
40Open the device for both reading and writing.
41It is usual to specify this flag.
42.TP
43.B O_NOCTTY
44Do not make this device the controlling terminal for the process.
47297adb 45.SH RETURN VALUE
4710caba 46On success,
104b099e 47.BR posix_openpt ()
ed09120a 48returns a file descriptor (a nonnegative integer) which is the lowest
d9cb0d7d 49numbered unused file descriptor.
8729177b 50On failure, \-1 is returned, and
4710caba
MK
51.I errno
52is set to indicate the error.
53.SH ERRORS
54See
55.BR open (2).
ee332a95
MK
56.SH VERSIONS
57Glibc support for
58.BR posix_openpt ()
59has been provided since version 2.2.1.
ebd03e29 60.SH ATTRIBUTES
9b940a23
PH
61For an explanation of the terms used in this section, see
62.BR attributes (7).
c466875e
MK
63.ad l
64.nh
9b940a23
PH
65.TS
66allbox;
c466875e 67lbx lb lb
9b940a23
PH
68l l l.
69Interface Attribute Value
70T{
ebd03e29 71.BR posix_openpt ()
9b940a23
PH
72T} Thread safety MT-Safe
73.TE
c466875e
MK
74.hy
75.ad
76.sp 1
47297adb 77.SH CONFORMING TO
a9fb6f01 78POSIX.1-2001, POSIX.1-2008.
847e0d88 79.PP
4710caba 80.BR posix_openpt ()
b218b023 81is part of the UNIX 98 pseudoterminal support (see
4710caba 82.BR pts (4)).
4710caba 83.SH NOTES
ebc28d13 84Some older UNIX implementations that support System V
b218b023 85(aka UNIX 98) pseudoterminals don't have this function, but it
fac73de4 86can be easily implemented by opening the pseudoterminal multiplexor device:
e646a1ba 87.PP
a08ea57c 88.in +4n
e646a1ba 89.EX
4710caba
MK
90int
91posix_openpt(int flags)
92{
93 return open("/dev/ptmx", flags);
94}
b8302363 95.EE
a08ea57c 96.in
66dd9100
MK
97.PP
98Calling
99.BR posix_openpt ()
100creates a pathname for the corresponding pseudoterminal slave device.
101The pathname of the slave device can be obtained using
102.BR ptsname (3).
103The slave device pathname exists only as long as the master device is open.
47297adb 104.SH SEE ALSO
4710caba
MK
105.BR open (2),
106.BR getpt (3),
107.BR grantpt (3),
108.BR ptsname (3),
b336ac27 109.BR unlockpt (3),
88ab292b
MK
110.BR pts (4),
111.BR pty (7)