localedef.1, access.2, ioctl_console.2, ioctl_fslabel.2, openat2.2, write.2, dlsym...
[man-pages.git] / man3 / getpt.3
blob6809893b1c6bb0a12bf92b335b548027aaf9b882
1 .\" This man page was written by Jeremy Phelps <jphelps@notreached.net>.
2 .\"
3 .\" %%%LICENSE_START(FREELY_REDISTRIBUTABLE)
4 .\" Redistribute and modify at will.
5 .\" %%%LICENSE_END
6 .\"
7 .TH GETPT 3 2021-03-22 "GNU" "Linux Programmer's Manual"
8 .SH NAME
9 getpt \- open a new pseudoterminal master
10 .SH SYNOPSIS
11 .nf
12 .BR "#define _GNU_SOURCE" "             /* See feature_test_macros(7) */"
13 .B #include <stdlib.h>
14 .PP
15 .B "int getpt(void);"
16 .fi
17 .SH DESCRIPTION
18 .BR getpt ()
19 opens a new pseudoterminal device and returns a file descriptor
20 that refers to that device.
21 It is equivalent to opening the pseudoterminal multiplexor device
22 .PP
23 .in +4n
24 .EX
25 open("/dev/ptmx", O_RDWR);
26 .EE
27 .in
28 .PP
29 on Linux systems, though the pseudoterminal multiplexor device is located
30 elsewhere on some systems that use the GNU C library.
31 .SH RETURN VALUE
32 .BR getpt ()
33 returns an open file descriptor upon successful completion.
34 Otherwise, it
35 returns \-1 and sets
36 .I errno
37 to indicate the error.
38 .SH ERRORS
39 .BR getpt ()
40 can fail with various errors described in
41 .BR open (2).
42 .SH VERSIONS
43 .BR getpt ()
44 is provided in glibc since version 2.1.
45 .SH ATTRIBUTES
46 For an explanation of the terms used in this section, see
47 .BR attributes (7).
48 .ad l
49 .nh
50 .TS
51 allbox;
52 lbx lb lb
53 l l l.
54 Interface       Attribute       Value
56 .BR getpt ()
57 T}      Thread safety   MT-Safe
58 .TE
59 .hy
60 .ad
61 .sp 1
62 .SH CONFORMING TO
63 .BR getpt ()
64 is glibc-specific;
65 use
66 .BR posix_openpt (3)
67 instead.
68 .SH SEE ALSO
69 .BR grantpt (3),
70 .BR posix_openpt (3),
71 .BR ptsname (3),
72 .BR unlockpt (3),
73 .BR ptmx (4),
74 .BR pty (7)