diff options
| author | millert <> | 2012-12-03 20:08:33 +0000 |
|---|---|---|
| committer | millert <> | 2012-12-03 20:08:33 +0000 |
| commit | ed1ef5fa1eac92dbaa0085484c0ae9062431733e (patch) | |
| tree | dcd259d2d99c6c999bb25321e53b0ea6d3fef8db /src/lib/libc/stdlib/posix_openpt.3 | |
| parent | 345bc900a13adaa14ff6b12c1e68c0e306c360af (diff) | |
| download | openbsd-ed1ef5fa1eac92dbaa0085484c0ae9062431733e.tar.gz openbsd-ed1ef5fa1eac92dbaa0085484c0ae9062431733e.tar.bz2 openbsd-ed1ef5fa1eac92dbaa0085484c0ae9062431733e.zip | |
Simple emulation of POSIX pty APIs posix_openpt(), ptsname(),
grantpt() and unlockpt() using /dev/ptm. Man pages from FreeBSD.
OK kettenis@ deraadt@ beck@ ajacoutot@ naddy@
Diffstat (limited to 'src/lib/libc/stdlib/posix_openpt.3')
| -rw-r--r-- | src/lib/libc/stdlib/posix_openpt.3 | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/src/lib/libc/stdlib/posix_openpt.3 b/src/lib/libc/stdlib/posix_openpt.3 new file mode 100644 index 0000000000..d292ac0a5f --- /dev/null +++ b/src/lib/libc/stdlib/posix_openpt.3 | |||
| @@ -0,0 +1,128 @@ | |||
| 1 | .\" $OpenBSD: posix_openpt.3,v 1.1 2012/12/03 20:08:33 millert Exp $ | ||
| 2 | .\" | ||
| 3 | .\" Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org> | ||
| 4 | .\" All rights reserved. | ||
| 5 | .\" | ||
| 6 | .\" Portions of this software were developed under sponsorship from Snow | ||
| 7 | .\" B.V., the Netherlands. | ||
| 8 | .\" | ||
| 9 | .\" Redistribution and use in source and binary forms, with or without | ||
| 10 | .\" modification, are permitted provided that the following conditions | ||
| 11 | .\" are met: | ||
| 12 | .\" 1. Redistributions of source code must retain the above copyright | ||
| 13 | .\" notice, this list of conditions and the following disclaimer. | ||
| 14 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
| 15 | .\" notice, this list of conditions and the following disclaimer in the | ||
| 16 | .\" documentation and/or other materials provided with the distribution. | ||
| 17 | .\" | ||
| 18 | .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
| 19 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 20 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 21 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 22 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 23 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 24 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 25 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 26 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 27 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 28 | .\" SUCH DAMAGE. | ||
| 29 | .\" | ||
| 30 | .\" Portions of this text are reprinted and reproduced in electronic form | ||
| 31 | .\" from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- | ||
| 32 | .\" Portable Operating System Interface (POSIX), The Open Group Base | ||
| 33 | .\" Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of | ||
| 34 | .\" Electrical and Electronics Engineers, Inc and The Open Group. In the | ||
| 35 | .\" event of any discrepancy between this version and the original IEEE and | ||
| 36 | .\" The Open Group Standard, the original IEEE and The Open Group Standard is | ||
| 37 | .\" the referee document. The original Standard can be obtained online at | ||
| 38 | .\" http://www.opengroup.org/unix/online.html. | ||
| 39 | .\" | ||
| 40 | .\" $FreeBSD: head/lib/libc/sys/posix_openpt.2 181905 2008-08-20 08:31:58Z ed $ | ||
| 41 | .\" | ||
| 42 | .Dd $Mdocdate: December 3 2012 $ | ||
| 43 | .Dt POSIX_OPENPT 3 | ||
| 44 | .Os | ||
| 45 | .Sh NAME | ||
| 46 | .Nm posix_openpt | ||
| 47 | .Nd "open a pseudo-terminal device" | ||
| 48 | .Sh SYNOPSIS | ||
| 49 | .In stdlib.h | ||
| 50 | .In fcntl.h | ||
| 51 | .Ft int | ||
| 52 | .Fn posix_openpt "int oflag" | ||
| 53 | .Sh DESCRIPTION | ||
| 54 | The | ||
| 55 | .Fn posix_openpt | ||
| 56 | function allocates a new pseudo-terminal and establishes a connection | ||
| 57 | with its master device. | ||
| 58 | After the pseudo-terminal has been allocated, the slave device should | ||
| 59 | have the proper permissions before it can be used (see | ||
| 60 | .Xr grantpt 3 ) . | ||
| 61 | The name of the slave device can be determined by calling | ||
| 62 | .Xr ptsname 3 . | ||
| 63 | .Pp | ||
| 64 | The file status flags and file access modes of the open file description | ||
| 65 | shall be set according to the value of | ||
| 66 | .Fa oflag . | ||
| 67 | Values for | ||
| 68 | .Fa oflag | ||
| 69 | are constructed by a bitwise-inclusive OR of flags from the following | ||
| 70 | list, defined in | ||
| 71 | .In fcntl.h : | ||
| 72 | .Bl -tag -width ".Dv O_NOCTTY" | ||
| 73 | .It Dv O_RDWR | ||
| 74 | Open for reading and writing. | ||
| 75 | .It Dv O_NOCTTY | ||
| 76 | If set | ||
| 77 | .Fn posix_openpt | ||
| 78 | shall not cause the terminal device to become the controlling terminal | ||
| 79 | for the process. | ||
| 80 | .El | ||
| 81 | .Pp | ||
| 82 | The | ||
| 83 | .Fn posix_openpt | ||
| 84 | function shall fail when | ||
| 85 | .Fa oflag | ||
| 86 | contains other values. | ||
| 87 | .Sh RETURN VALUES | ||
| 88 | Upon successful completion, the | ||
| 89 | .Fn posix_openpt | ||
| 90 | function shall allocate a new pseudo-terminal device and return a | ||
| 91 | non-negative integer representing a file descriptor, which is connected | ||
| 92 | to its master device. | ||
| 93 | Otherwise, -1 shall be returned and errno set to indicate the error. | ||
| 94 | .Sh ERRORS | ||
| 95 | The | ||
| 96 | .Fn posix_openpt | ||
| 97 | function shall fail if: | ||
| 98 | .Bl -tag -width Er | ||
| 99 | .It Bq Er EMFILE | ||
| 100 | The per-process descriptor table is full. | ||
| 101 | .It Bq Er ENFILE | ||
| 102 | The system file table is full. | ||
| 103 | .It Bq Er EINVAL | ||
| 104 | The value of | ||
| 105 | .Fa oflag | ||
| 106 | is not valid. | ||
| 107 | .El | ||
| 108 | .Sh SEE ALSO | ||
| 109 | .Xr ptsname 3 , | ||
| 110 | .Xr pty 4 , | ||
| 111 | .Xr tty 4 | ||
| 112 | .Sh STANDARDS | ||
| 113 | The | ||
| 114 | .Fn posix_openpt | ||
| 115 | function conforms to | ||
| 116 | .St -p1003.1-2001 . | ||
| 117 | .Sh HISTORY | ||
| 118 | The | ||
| 119 | .Fn posix_openpt | ||
| 120 | function appeared in | ||
| 121 | .Ox 5.3 . | ||
| 122 | .Sh CAVEATS | ||
| 123 | The flag | ||
| 124 | .Dv O_NOCTTY | ||
| 125 | is included for compatibility; in | ||
| 126 | .Ox , | ||
| 127 | opening a terminal does not cause it to become a process's controlling | ||
| 128 | terminal. | ||
