]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/posix_openpt.3
Wrapped long lines, wrapped at sentence boundaries; stripped trailing
[thirdparty/man-pages.git] / man3 / posix_openpt.3
CommitLineData
4710caba
MK
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.
c13182ef 13.\"
4710caba
MK
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.
c13182ef 21.\"
4710caba
MK
22.\" Formatted or processed versions of this manual, if unaccompanied by
23.\" the source, must acknowledge the copyright and authors of this work.
24.\"
0393ebd0 25.TH POSIX_OPENPT 3 "2007-01-08" "PTY Control" "Linux Programmer's Manual"
4710caba
MK
26.SH NAME
27posix_openpt \- open a pseudo-terminal device
28.SH SYNOPSIS
29.nf
4ae1d7b9 30.B #define _XOPEN_SOURCE 600
4710caba
MK
31.br
32.B #include <stdlib.h>
33.B #include <fcntl.h>
34.sp
92e6a919 35.BI "int posix_openpt(int " flags ");"
4710caba
MK
36.fi
37.SH DESCRIPTION
38The
39.BR posix_openpt ()
40function opens an unused pseudo-terminal master device, returning a
41file descriptor that can be used to refer to that device.
42
43The
44.I flags
45argument is a bit mask that ORs together zero or more of
46the following flags:
47.TP
704a18f0 48.B O_RDWR
4710caba
MK
49Open the device for both reading and writing.
50It is usual to specify this flag.
51.TP
52.B O_NOCTTY
53Do not make this device the controlling terminal for the process.
54.SH "RETURN VALUE"
55On success,
104b099e 56.BR posix_openpt ()
4710caba
MK
57returns a non-negative file descriptor which is the lowest
58numbered unused descriptor.
8729177b 59On failure, \-1 is returned, and
4710caba
MK
60.I errno
61is set to indicate the error.
62.SH ERRORS
63See
64.BR open (2).
65.SH "CONFORMING TO"
66.BR posix_openpt ()
67is part of the Unix98 pseudo-terminal support (see
68.BR pts (4)).
68e1685c 69This function is specified in POSIX.1-2001.
4710caba
MK
70.SH NOTES
71This function is a recent invention in POSIX.
72Some Unix implementations that support System V
73(aka Unix 98) pseudo-terminals don't have this function, but it
74is easy to implement:
75.in +0.5i
76.nf
77
78int
79posix_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),
88ab292b 91.BR pts (4),
0a90178c 92.BR feature_test_macros (7),
88ab292b 93.BR pty (7)