summaryrefslogtreecommitdiffstats
path: root/upstream/fedora-rawhide/man3/posix_openpt.3
blob: 79f6af9b5b0dba12a8aaa3492e48d27034c9a88b (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
'\" t
.\" Copyright (C) 2004 Michael Kerrisk
.\"
.\" SPDX-License-Identifier: Linux-man-pages-copyleft
.\"
.TH posix_openpt 3 2023-10-31 "Linux man-pages 6.06"
.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>
.P
.BI "int posix_openpt(int " flags ");"
.fi
.P
.RS -4
Feature Test Macro Requirements for glibc (see
.BR feature_test_macros (7)):
.RE
.P
.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.
.P
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
.SH STANDARDS
POSIX.1-2008.
.SH HISTORY
glibc 2.2.1.
POSIX.1-2001.
.P
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:
.P
.in +4n
.EX
int
posix_openpt(int flags)
{
    return open("/dev/ptmx", flags);
}
.EE
.in
.P
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)