OSDN Git Service

a831dccfbd9a959aa2e5c248e526e2858c652f67
[linuxjm/LDP_man-pages.git] / original / man3 / posix_openpt.3
1 .\" Copyright (C) 2004 Michael Kerrisk
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
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.
12 .\"
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.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .TH POSIX_OPENPT 3 2012-04-20 "" "Linux Programmer's Manual"
26 .SH NAME
27 posix_openpt \- open a pseudoterminal device
28 .SH SYNOPSIS
29 .nf
30 .B #include <stdlib.h>
31 .B #include <fcntl.h>
32 .sp
33 .BI "int posix_openpt(int " flags ");"
34 .fi
35 .sp
36 .in -4n
37 Feature Test Macro Requirements for glibc (see
38 .BR feature_test_macros (7)):
39 .in
40 .sp
41 .ad l
42 .BR posix_openpt ():
43 _XOPEN_SOURCE\ >=\ 600
44 .ad b
45 .SH DESCRIPTION
46 The
47 .BR posix_openpt ()
48 function opens an unused pseudoterminal master device, returning a
49 file descriptor that can be used to refer to that device.
50
51 The
52 .I flags
53 argument is a bit mask that ORs together zero or more of
54 the following flags:
55 .TP
56 .B O_RDWR
57 Open the device for both reading and writing.
58 It is usual to specify this flag.
59 .TP
60 .B O_NOCTTY
61 Do not make this device the controlling terminal for the process.
62 .SH RETURN VALUE
63 On success,
64 .BR posix_openpt ()
65 returns a nonnegative file descriptor which is the lowest
66 numbered unused descriptor.
67 On failure, \-1 is returned, and
68 .I errno
69 is set to indicate the error.
70 .SH ERRORS
71 See
72 .BR open (2).
73 .SH VERSIONS
74 Glibc support for
75 .BR posix_openpt ()
76 has been provided since version 2.2.1.
77 .SH CONFORMING TO
78 .BR posix_openpt ()
79 is part of the UNIX 98 pseudoterminal support (see
80 .BR pts (4)).
81 This function is specified in POSIX.1-2001.
82 .SH NOTES
83 The
84 .BR posix_openpt ()
85 function is a recent invention in POSIX.
86 Some UNIX implementations that support System V
87 (aka UNIX 98) pseudoterminals don't have this function, but it
88 is easy to implement:
89 .in +4n
90 .nf
91
92 int
93 posix_openpt(int flags)
94 {
95     return open("/dev/ptmx", flags);
96 }
97 .fi
98 .in
99 .PP
100 Calling
101 .BR posix_openpt ()
102 creates a pathname for the corresponding pseudoterminal slave device.
103 The pathname of the slave device can be obtained using
104 .BR ptsname (3).
105 The slave device pathname exists only as long as the master device is open.
106 .SH SEE ALSO
107 .BR open (2),
108 .BR getpt (3),
109 .BR grantpt (3),
110 .BR ptsname (3),
111 .BR unlockpt (3),
112 .BR pts (4),
113 .BR pty (7)
114 .SH COLOPHON
115 This page is part of release 3.64 of the Linux
116 .I man-pages
117 project.
118 A description of the project,
119 and information about reporting bugs,
120 can be found at
121 \%http://www.kernel.org/doc/man\-pages/.