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

NAME

6       posix_openpt - open a pseudo-terminal 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(): _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600
17

DESCRIPTION

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

RETURN VALUE

34       On success, posix_openpt() returns a non-negative file descriptor which
35       is  the lowest numbered unused descriptor.  On failure, -1 is returned,
36       and errno is set to indicate the error.
37

ERRORS

39       See open(2).
40

VERSIONS

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

CONFORMING TO

45       posix_openpt() is part  of  the  Unix98  pseudo-terminal  support  (see
46       pts(4)).  This function is specified in POSIX.1-2001.
47

NOTES

49       This  function  is  a recent invention in POSIX.  Some Unix implementa‐
50       tions that support System V (aka Unix 98) pseudo-terminals  don't  have
51       this function, but it is easy to implement:
52
53           int
54           posix_openpt(int flags)
55           {
56               return open("/dev/ptmx", flags);
57           }
58

SEE ALSO

60       open(2), getpt(3), grantpt(3), ptsname(3), unlockpt(3), pts(4), pty(7)
61

COLOPHON

63       This  page  is  part of release 3.22 of the Linux man-pages project.  A
64       description of the project, and information about reporting  bugs,  can
65       be found at http://www.kernel.org/doc/man-pages/.
66
67
68
69                                  2007-07-26                   POSIX_OPENPT(3)
Impressum