1*f14fb602SLionel Sambuc.\" $NetBSD: posix_openpt.3,v 1.6 2011/05/05 07:36:44 wiz Exp $ 22fe8fb19SBen Gras.\" 32fe8fb19SBen Gras.\" Copyright (c) 2004 The NetBSD Foundation, Inc. 42fe8fb19SBen Gras.\" All rights reserved. 52fe8fb19SBen Gras.\" 62fe8fb19SBen Gras.\" This code is derived from software contributed to The NetBSD Foundation 72fe8fb19SBen Gras.\" by Christos Zoulas. 82fe8fb19SBen Gras.\" 92fe8fb19SBen Gras.\" Redistribution and use in source and binary forms, with or without 102fe8fb19SBen Gras.\" modification, are permitted provided that the following conditions 112fe8fb19SBen Gras.\" are met: 122fe8fb19SBen Gras.\" 1. Redistributions of source code must retain the above copyright 132fe8fb19SBen Gras.\" notice, this list of conditions and the following disclaimer. 142fe8fb19SBen Gras.\" 2. Redistributions in binary form must reproduce the above copyright 152fe8fb19SBen Gras.\" notice, this list of conditions and the following disclaimer in the 162fe8fb19SBen Gras.\" documentation and/or other materials provided with the distribution. 172fe8fb19SBen Gras.\" 182fe8fb19SBen Gras.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 192fe8fb19SBen Gras.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 202fe8fb19SBen Gras.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 212fe8fb19SBen Gras.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 222fe8fb19SBen Gras.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 232fe8fb19SBen Gras.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 242fe8fb19SBen Gras.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 252fe8fb19SBen Gras.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 262fe8fb19SBen Gras.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 272fe8fb19SBen Gras.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 282fe8fb19SBen Gras.\" POSSIBILITY OF SUCH DAMAGE. 292fe8fb19SBen Gras.\" 302fe8fb19SBen Gras.Dd May 25, 2004 312fe8fb19SBen Gras.Dt POSIX_OPENPT 3 322fe8fb19SBen Gras.Os 332fe8fb19SBen Gras.Sh NAME 342fe8fb19SBen Gras.Nm posix_openpt 352fe8fb19SBen Gras.Nd open a pseudo-terminal device 362fe8fb19SBen Gras.Sh LIBRARY 372fe8fb19SBen Gras.Lb libc 382fe8fb19SBen Gras.Sh SYNOPSIS 392fe8fb19SBen Gras.In stdlib.h 402fe8fb19SBen Gras.In fcntl.h 412fe8fb19SBen Gras.Ft int 422fe8fb19SBen Gras.Fn posix_openpt "int oflag" 432fe8fb19SBen Gras.Sh DESCRIPTION 44*f14fb602SLionel SambucThe 452fe8fb19SBen Gras.Fn posix_openpt 46*f14fb602SLionel Sambucfunction searches for an unused master pseudo-terminal device, 47*f14fb602SLionel Sambucopens it, and returns a file descriptor associated with the now 48*f14fb602SLionel Sambucused pseudo-terminal device. 492fe8fb19SBen GrasThe 502fe8fb19SBen Gras.Fa oflag 512fe8fb19SBen Grasargument has the same meaning as in the 522fe8fb19SBen Gras.Xr open 2 532fe8fb19SBen Grascall. 542fe8fb19SBen Gras.Sh RETURN VALUES 552fe8fb19SBen GrasIf successful, 562fe8fb19SBen Gras.Fn posix_openpt 572fe8fb19SBen Grasreturns a non-negative integer, which corresponds to a file descriptor 582fe8fb19SBen Graspointing to the master pseudo-terminal device. 592fe8fb19SBen GrasOtherwise, a value of \-1 is returned and 602fe8fb19SBen Gras.Va errno 612fe8fb19SBen Grasis set to indicate the error. 622fe8fb19SBen Gras.Sh SEE ALSO 632fe8fb19SBen Gras.Xr ioctl 2 , 642fe8fb19SBen Gras.Xr open 2 , 652fe8fb19SBen Gras.Xr grantpt 3 , 662fe8fb19SBen Gras.Xr ptsname 3 , 672fe8fb19SBen Gras.Xr unlockpt 3 682fe8fb19SBen Gras.Sh RATIONALE 692fe8fb19SBen GrasThe standards committee did not want to directly expose the cloning device, 702fe8fb19SBen Grasthus decided to wrap the functionality in this function. 712fe8fb19SBen GrasThe equivalent code would be: 722fe8fb19SBen Gras.Bd -literal 732fe8fb19SBen Gras int 742fe8fb19SBen Gras posix_openpt(int oflag) { 752fe8fb19SBen Gras return open("/dev/ptmx", oflag); 762fe8fb19SBen Gras } 772fe8fb19SBen Gras.Ed 782fe8fb19SBen Gras.Sh STANDARDS 792fe8fb19SBen GrasThe 802fe8fb19SBen Gras.Fn posix_openpt 812fe8fb19SBen Grasfunction conforms to 822fe8fb19SBen Gras.St -p1003.1-2001 . 83