1posix_openpt(3)            Library Functions Manual            posix_openpt(3)
2
3
4

NAME

6       posix_openpt - open a pseudoterminal device
7

LIBRARY

9       Standard C library (libc, -lc)
10

SYNOPSIS

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

DESCRIPTION

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

RETURN VALUE

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

ERRORS

43       See open(2).
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

STANDARDS

56       POSIX.1-2008.
57

HISTORY

59       glibc 2.2.1.  POSIX.1-2001.
60
61       It is part of the UNIX 98 pseudoterminal support (see pts(4)).
62

NOTES

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

SEE ALSO

80       open(2), getpt(3), grantpt(3), ptsname(3), unlockpt(3), pts(4), pty(7)
81
82
83
84Linux man-pages 6.04              2023-03-30                   posix_openpt(3)
Impressum