]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/posix_openpt.3
Wrapped long lines, wrapped at sentence boundaries; stripped trailing
[thirdparty/man-pages.git] / man3 / posix_openpt.3
1 .\" Hey Emacs! This file is -*- nroff -*- source.
2 .\"
3 .\" Copyright (C) 2004 Michael Kerrisk
4 .\"
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
8 .\"
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
13 .\"
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date. The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein. The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\"
25 .TH POSIX_OPENPT 3 "2007-01-08" "PTY Control" "Linux Programmer's Manual"
26 .SH NAME
27 posix_openpt \- open a pseudo-terminal device
28 .SH SYNOPSIS
29 .nf
30 .B #define _XOPEN_SOURCE 600
31 .br
32 .B #include <stdlib.h>
33 .B #include <fcntl.h>
34 .sp
35 .BI "int posix_openpt(int " flags ");"
36 .fi
37 .SH DESCRIPTION
38 The
39 .BR posix_openpt ()
40 function opens an unused pseudo-terminal master device, returning a
41 file descriptor that can be used to refer to that device.
42
43 The
44 .I flags
45 argument is a bit mask that ORs together zero or more of
46 the following flags:
47 .TP
48 .B O_RDWR
49 Open the device for both reading and writing.
50 It is usual to specify this flag.
51 .TP
52 .B O_NOCTTY
53 Do not make this device the controlling terminal for the process.
54 .SH "RETURN VALUE"
55 On success,
56 .BR posix_openpt ()
57 returns a non-negative file descriptor which is the lowest
58 numbered unused descriptor.
59 On failure, \-1 is returned, and
60 .I errno
61 is set to indicate the error.
62 .SH ERRORS
63 See
64 .BR open (2).
65 .SH "CONFORMING TO"
66 .BR posix_openpt ()
67 is part of the Unix98 pseudo-terminal support (see
68 .BR pts (4)).
69 This function is specified in POSIX.1-2001.
70 .SH NOTES
71 This function is a recent invention in POSIX.
72 Some Unix implementations that support System V
73 (aka Unix 98) pseudo-terminals don't have this function, but it
74 is easy to implement:
75 .in +0.5i
76 .nf
77
78 int
79 posix_openpt(int flags)
80 {
81 return open("/dev/ptmx", flags);
82 }
83 .fi
84 .in -0.5i
85 .SH "SEE ALSO"
86 .BR open (2),
87 .BR getpt (3),
88 .BR grantpt (3),
89 .BR ptsname (3),
90 .BR unlock (3),
91 .BR pts (4),
92 .BR feature_test_macros (7),
93 .BR pty (7)