Debian Codegraph @

upstream/debian-unstable/man3/getpt.3

raw
1 '\" t
2 .\" Copyright, the authors of the Linux man-pages project
3 .\"
4 .\" %%%LICENSE_START(FREELY_REDISTRIBUTABLE)
5 .\" Redistribute and modify at will.
6 .\" %%%LICENSE_END
7 .\"
8 .TH getpt 3 2025-12-26 "Linux man-pages 6.18"
9 .SH NAME
10 getpt \- open a new pseudoterminal master
11 .SH LIBRARY
12 Standard C library
13 .RI ( libc ,\~ \-lc )
14 .SH SYNOPSIS
15 .nf
16 .BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */"
17 .B #include <stdlib.h>
18 .P
19 .B "int getpt(void);"
20 .fi
21 .SH DESCRIPTION
22 .BR getpt ()
23 opens a new pseudoterminal device and returns a file descriptor
24 that refers to that device.
25 It is equivalent to opening the pseudoterminal multiplexer device
26 .P
27 .in +4n
28 .EX
29 open("/dev/ptmx", O_RDWR);
30 .EE
31 .in
32 .P
33 on Linux systems, though the pseudoterminal multiplexer device is located
34 elsewhere on some systems that use the GNU C library.
35 .SH RETURN VALUE
36 .BR getpt ()
37 returns an open file descriptor upon successful completion.
38 Otherwise, it
39 returns \-1 and sets
40 .I errno
41 to indicate the error.
42 .SH ERRORS
43 .BR getpt ()
44 can fail with various errors described in
45 .BR open (2).
46 .SH ATTRIBUTES
47 For an explanation of the terms used in this section, see
48 .BR attributes (7).
49 .TS
50 allbox;
51 lbx lb lb
52 l l l.
53 Interface Attribute Value
54 T{
55 .na
56 .nh
57 .BR getpt ()
58 T} Thread safety MT-Safe
59 .TE
60 .SH VERSIONS
61 Use
62 .BR posix_openpt (3)
63 instead.
64 .SH STANDARDS
65 GNU.
66 .SH HISTORY
67 glibc 2.1.
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)