]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/posix_openpt.3
_exit.2, bpf.2, cacheflush.2, capget.2, chdir.2, chmod.2, chroot.2, clock_getres...
[thirdparty/man-pages.git] / man3 / posix_openpt.3
CommitLineData
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.\"
97986708 25.TH POSIX_OPENPT 3 2016-03-15 "" "Linux Programmer's Manual"
4710caba 26.SH NAME
b218b023 27posix_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
37Feature 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
46The
47.BR posix_openpt ()
b218b023 48function opens an unused pseudoterminal master device, returning a
4710caba
MK
49file descriptor that can be used to refer to that device.
50
51The
52.I flags
53argument is a bit mask that ORs together zero or more of
54the following flags:
55.TP
704a18f0 56.B O_RDWR
4710caba
MK
57Open the device for both reading and writing.
58It is usual to specify this flag.
59.TP
60.B O_NOCTTY
61Do not make this device the controlling terminal for the process.
47297adb 62.SH RETURN VALUE
4710caba 63On success,
104b099e 64.BR posix_openpt ()
2fda57bd 65returns a nonnegative file descriptor which is the lowest
d9cb0d7d 66numbered unused file descriptor.
8729177b 67On failure, \-1 is returned, and
4710caba
MK
68.I errno
69is set to indicate the error.
70.SH ERRORS
71See
72.BR open (2).
ee332a95
MK
73.SH VERSIONS
74Glibc support for
75.BR posix_openpt ()
76has been provided since version 2.2.1.
ebd03e29 77.SH ATTRIBUTES
9b940a23
PH
78For an explanation of the terms used in this section, see
79.BR attributes (7).
80.TS
81allbox;
82lb lb lb
83l l l.
84Interface Attribute Value
85T{
ebd03e29 86.BR posix_openpt ()
9b940a23
PH
87T} Thread safety MT-Safe
88.TE
47297adb 89.SH CONFORMING TO
a9fb6f01
MK
90POSIX.1-2001, POSIX.1-2008.
91
4710caba 92.BR posix_openpt ()
b218b023 93is part of the UNIX 98 pseudoterminal support (see
4710caba 94.BR pts (4)).
4710caba 95.SH NOTES
ebc28d13 96Some older UNIX implementations that support System V
b218b023 97(aka UNIX 98) pseudoterminals don't have this function, but it
4710caba 98is easy to implement:
a08ea57c 99.in +4n
4710caba
MK
100.nf
101
102int
103posix_openpt(int flags)
104{
105 return open("/dev/ptmx", flags);
106}
107.fi
a08ea57c 108.in
66dd9100
MK
109.PP
110Calling
111.BR posix_openpt ()
112creates a pathname for the corresponding pseudoterminal slave device.
113The pathname of the slave device can be obtained using
114.BR ptsname (3).
115The 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)