xref: /openbsd-src/lib/libc/stdlib/posix_openpt.3 (revision bf198cc6eba0ca1f6d79f71e8e2243d386241fa8)
1*bf198cc6Smillert.\"     $OpenBSD: posix_openpt.3,v 1.4 2019/01/25 00:19:25 millert Exp $
28d2ec7eaSmillert.\"
3*bf198cc6Smillert.\" Copyright (c) 2012 Todd C. Miller <millert@openbsd.org>
48d2ec7eaSmillert.\"
5666c04e0Smillert.\" Permission to use, copy, modify, and distribute this software for any
6666c04e0Smillert.\" purpose with or without fee is hereby granted, provided that the above
7666c04e0Smillert.\" copyright notice and this permission notice appear in all copies.
88d2ec7eaSmillert.\"
9666c04e0Smillert.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10666c04e0Smillert.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11666c04e0Smillert.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12666c04e0Smillert.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13666c04e0Smillert.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14666c04e0Smillert.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15666c04e0Smillert.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
168d2ec7eaSmillert.\"
17*bf198cc6Smillert.Dd $Mdocdate: January 25 2019 $
188d2ec7eaSmillert.Dt POSIX_OPENPT 3
198d2ec7eaSmillert.Os
208d2ec7eaSmillert.Sh NAME
218d2ec7eaSmillert.Nm posix_openpt
22666c04e0Smillert.Nd open a pseudo-terminal device
238d2ec7eaSmillert.Sh SYNOPSIS
248d2ec7eaSmillert.In stdlib.h
258d2ec7eaSmillert.In fcntl.h
268d2ec7eaSmillert.Ft int
278d2ec7eaSmillert.Fn posix_openpt "int oflag"
288d2ec7eaSmillert.Sh DESCRIPTION
298d2ec7eaSmillertThe
308d2ec7eaSmillert.Fn posix_openpt
31666c04e0Smillertfunction finds the next available pseudo-terminal and returns an open
32666c04e0Smillertfile descriptor for its master device.
33666c04e0SmillertThe path name of the slave device may be determined via the
34666c04e0Smillert.Fn ptsname
35666c04e0Smillertfunction.
36666c04e0SmillertNote that the
37666c04e0Smillert.Fn unlockpt
38666c04e0Smillertand
39666c04e0Smillert.Fn grantpt
40666c04e0Smillertfunctions should be called before opening the slave device.
418d2ec7eaSmillert.Pp
42666c04e0SmillertThe
43666c04e0Smillert.Ar oflag
44666c04e0Smillertargument is formed by bitwise-inclusive
45666c04e0Smillert.Tn OR Ns 'ing
46666c04e0Smillertthe following values defined in
478d2ec7eaSmillert.In fcntl.h :
48666c04e0Smillert.Bl -tag -width O_NOCTTY -offset indent
498d2ec7eaSmillert.It Dv O_RDWR
508d2ec7eaSmillertOpen for reading and writing.
518d2ec7eaSmillert.It Dv O_NOCTTY
52666c04e0SmillertPrevent the device from being made the controlling terminal for the session.
53666c04e0SmillertThis flag has no effect on
54666c04e0Smillert.Ox
55666c04e0Smillertand is included for compatibility with other systems.
568d2ec7eaSmillert.El
578d2ec7eaSmillert.Pp
588d2ec7eaSmillertThe
59666c04e0Smillert.Dv O_RDWR
60666c04e0Smillertflag must be specified in
61666c04e0Smillert.Fa oflag .
62666c04e0SmillertIf
638d2ec7eaSmillert.Fa oflag
64666c04e0Smillertcontains values other than those listed above,
658d2ec7eaSmillert.Fn posix_openpt
66666c04e0Smillertwill return an error.
67666c04e0Smillert.Sh RETURN VALUES
68666c04e0SmillertIf successful,
69666c04e0Smillert.Fn posix_openpt
70666c04e0Smillertreturns a non-negative integer, the file descriptor for the
71666c04e0Smillertpseudo-terminal master device.
72666c04e0SmillertOtherwise, a value of \-1 is returned and
73666c04e0Smillert.Va errno
74666c04e0Smillertis set to indicate the error.
758d2ec7eaSmillert.Sh ERRORS
768d2ec7eaSmillertThe
778d2ec7eaSmillert.Fn posix_openpt
78666c04e0Smillertfunction will fail if:
798d2ec7eaSmillert.Bl -tag -width Er
808d2ec7eaSmillert.It Bq Er EMFILE
818d2ec7eaSmillertThe per-process descriptor table is full.
828d2ec7eaSmillert.It Bq Er ENFILE
838d2ec7eaSmillertThe system file table is full.
848d2ec7eaSmillert.It Bq Er EINVAL
858d2ec7eaSmillertThe value of
868d2ec7eaSmillert.Fa oflag
878d2ec7eaSmillertis not valid.
888d2ec7eaSmillert.El
898d2ec7eaSmillert.Sh SEE ALSO
908d2ec7eaSmillert.Xr ptsname 3 ,
918d2ec7eaSmillert.Xr pty 4 ,
928d2ec7eaSmillert.Xr tty 4
938d2ec7eaSmillert.Sh STANDARDS
948d2ec7eaSmillertThe
958d2ec7eaSmillert.Fn posix_openpt
968d2ec7eaSmillertfunction conforms to
978d2ec7eaSmillert.St -p1003.1-2001 .
988d2ec7eaSmillert.Sh HISTORY
998d2ec7eaSmillertThe
1008d2ec7eaSmillert.Fn posix_openpt
1018d2ec7eaSmillertfunction appeared in
1028d2ec7eaSmillert.Ox 5.3 .
103