1POSIX_OPENPT(3)            Linux Programmer's Manual           POSIX_OPENPT(3)
2
3
4

NAME

6       posix_openpt - open a pseudoterminal device
7

SYNOPSIS

9       #include <stdlib.h>
10       #include <fcntl.h>
11
12       int posix_openpt(int flags);
13
14   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
15
16       posix_openpt():
17           _XOPEN_SOURCE >= 600
18

DESCRIPTION

20       The  posix_openpt()  function opens an unused pseudoterminal master de‐
21       vice, returning a file descriptor that can be used to refer to that de‐
22       vice.
23
24       The  flags argument is a bit mask that ORs together zero or more of the
25       following flags:
26
27       O_RDWR Open the device for both reading and writing.  It  is  usual  to
28              specify this flag.
29
30       O_NOCTTY
31              Do  not  make  this  device  the  controlling  terminal  for the
32              process.
33

RETURN VALUE

35       On success, posix_openpt() returns a file descriptor (a nonnegative in‐
36       teger)  which  is the lowest numbered unused file descriptor.  On fail‐
37       ure, -1 is returned, and errno is set to indicate the error.
38

ERRORS

40       See open(2).
41

VERSIONS

43       Glibc support for posix_openpt() has been provided since version 2.2.1.
44

ATTRIBUTES

46       For an  explanation  of  the  terms  used  in  this  section,  see  at‐
47       tributes(7).
48
49       ┌────────────────────────────────────────────┬───────────────┬─────────┐
50Interface                                   Attribute     Value   
51       ├────────────────────────────────────────────┼───────────────┼─────────┤
52posix_openpt()                              │ Thread safety │ MT-Safe │
53       └────────────────────────────────────────────┴───────────────┴─────────┘
54

CONFORMING TO

56       POSIX.1-2001, POSIX.1-2008.
57
58       posix_openpt()  is  part  of  the  UNIX  98 pseudoterminal support (see
59       pts(4)).
60

NOTES

62       Some older UNIX implementations that support System  V  (aka  UNIX  98)
63       pseudoterminals  don't  have this function, but it can be easily imple‐
64       mented by opening the pseudoterminal multiplexor device:
65
66           int
67           posix_openpt(int flags)
68           {
69               return open("/dev/ptmx", flags);
70           }
71
72       Calling posix_openpt() creates a pathname for the  corresponding  pseu‐
73       doterminal  slave  device.  The pathname of the slave device can be ob‐
74       tained using ptsname(3).  The slave device pathname exists only as long
75       as the master device is open.
76

SEE ALSO

78       open(2), getpt(3), grantpt(3), ptsname(3), unlockpt(3), pts(4), pty(7)
79

COLOPHON

81       This  page  is  part of release 5.12 of the Linux man-pages project.  A
82       description of the project, information about reporting bugs,  and  the
83       latest     version     of     this    page,    can    be    found    at
84       https://www.kernel.org/doc/man-pages/.
85
86
87
88                                  2021-03-22                   POSIX_OPENPT(3)
Impressum