summaryrefslogtreecommitdiffstats
path: root/upstream/debian-unstable/man3/posix_openpt.3
blob: 09733d0a4d4d950afa3ef6bd4510856a9ed3f639 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
'\" t
.\" Copyright (C) 2004 Michael Kerrisk
.\"
.\" SPDX-License-Identifier: Linux-man-pages-copyleft
.\"
.TH posix_openpt 3 2023-07-20 "Linux man-pages 6.05.01"
.SH NAME
posix_openpt \- open a pseudoterminal device
.SH LIBRARY
Standard C library
.RI ( libc ", " \-lc )
.SH SYNOPSIS
.nf
.B #include <stdlib.h>
.B #include <fcntl.h>
.PP
.BI "int posix_openpt(int " flags ");"
.fi
.PP
.RS -4
Feature Test Macro Requirements for glibc (see
.BR feature_test_macros (7)):
.RE
.PP
.BR posix_openpt ():
.nf
    _XOPEN_SOURCE >= 600
.fi
.SH DESCRIPTION
The
.BR posix_openpt ()
function opens an unused pseudoterminal master device, returning a
file descriptor that can be used to refer to that device.
.PP
The
.I flags
argument is a bit mask that ORs together zero or more of
the following flags:
.TP
.B O_RDWR
Open the device for both reading and writing.
It is usual to specify this flag.
.TP
.B O_NOCTTY
Do not make this device the controlling terminal for the process.
.SH RETURN VALUE
On success,
.BR posix_openpt ()
returns a file descriptor (a nonnegative integer) which is the lowest
numbered unused file descriptor.
On failure, \-1 is returned, and
.I errno
is set to indicate the error.
.SH ERRORS
See
.BR open (2).
.SH ATTRIBUTES
For an explanation of the terms used in this section, see
.BR attributes (7).
.TS
allbox;
lbx lb lb
l l l.
Interface	Attribute	Value
T{
.na
.nh
.BR posix_openpt ()
T}	Thread safety	MT-Safe
.TE
.sp 1
.SH STANDARDS
POSIX.1-2008.
.SH HISTORY
glibc 2.2.1.
POSIX.1-2001.
.PP
It is part of the UNIX 98 pseudoterminal support (see
.BR pts (4)).
.SH NOTES
Some older UNIX implementations that support System V
(aka UNIX 98) pseudoterminals don't have this function, but it
can be easily implemented by opening the pseudoterminal multiplexor device:
.PP
.in +4n
.EX
int
posix_openpt(int flags)
{
    return open("/dev/ptmx", flags);
}
.EE
.in
.PP
Calling
.BR posix_openpt ()
creates a pathname for the corresponding pseudoterminal slave device.
The pathname of the slave device can be obtained using
.BR ptsname (3).
The slave device pathname exists only as long as the master device is open.
.SH SEE ALSO
.BR open (2),
.BR getpt (3),
.BR grantpt (3),
.BR ptsname (3),
.BR unlockpt (3),
.BR pts (4),
.BR pty (7)