.\" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
.\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $FreeBSD: src/lib/libc/stdlib/grantpt.3,v 1.1 2003/01/02 20:44:41 jmallett Exp $
+.\" $FreeBSD: src/lib/libc/stdlib/grantpt.3,v 1.3 2003/09/14 13:41:57 ru Exp $
.\"
.Dd December 23, 2002
.Os
.In stdlib.h
.Ft int
.Fn grantpt "int fildes"
-.Ft char *
+.Ft "char *"
.Fn ptsname "int fildes"
.Ft int
.Fn unlockpt "int fildes"
function is used to establish ownership and permissions
of the slave device counterpart to the master device
specified with
-.Va fildes .
+.Fa fildes .
The slave device's ownership is set to the real user ID
of the calling process, and the permissions are set to
user readable-writable and group writable.
The group owner of the slave device is also set to the
-group "tty" if it exists on the system; otherwise, it
+group
+.Dq Li tty
+if it exists on the system; otherwise, it
is left untouched.
.Pp
The
.Fn ptsname
function returns the full pathname of the slave device
counterpart to the master device specified with
-.Va fildes .
+.Fa fildes .
This value can be used
to subsequently open the appropriate slave after
.Fn posix_openpt
.Fn unlockpt
function clears the lock held on the pseudo-terminal pair
for the master device specified with
-.Va fildes .
+.Fa fildes .
.Pp
The
.Fn posix_openpt
function opens the first available master pseudo-terminal
device and returns a descriptor to it.
-.Va mode
+The
+.Fa mode
+argument
specifies the flags used for opening the device:
-.Bl -tag -width O_NOCTTY
+.Bl -tag -width ".Dv O_NOCTTY"
.It Dv O_RDWR
Open for reading and writing.
.It Dv O_NOCTTY
the controlling terminal for the calling process.
.El
.Sh RETURN VALUES
-The
-.Fn grantpt
-and
-.Fn unlockpt
-functions return 0 on success; otherwise -1 is returned and
-.Va errno
-is set to indicate the error.
+.Rv -std grantpt unlockpt
.Pp
The
.Fn ptsname
function returns a pointer to the name
-of the slave device on success;
-otherwise a NULL pointer is returned and
+of the slave device on success; otherwise a
+.Dv NULL
+pointer is returned and the global variable
.Va errno
is set to indicate the error.
.Pp
.Fn posix_openpt
function returns a file descriptor to the first
available master pseudo-terminal device on success;
-otherwise -1 is returned and
+otherwise \-1 is returned and the global variable
.Va errno
is set to indicate the error.
.Sh ERRORS
.Va errno
to:
.Bl -tag -width Er
-.It EINVAL
-.Va fildes
+.It Bq Er EINVAL
+.Fa fildes
is not a master pseudo-terminal device.
.El
.Pp
.Va errno
to:
.Bl -tag -width Er
-.It EACCES
+.It Bq Er EACCES
The slave pseudo-terminal device could not be accessed.
.El
.Pp
.Va errno
to:
.Bl -tag -width Er
-.It EINVAL
-.Va mode
-consists an an invalid mode bit.
-.It EAGAIN
+.It Bq Er EINVAL
+.Fa mode
+consists of an invalid mode bit.
+.It Bq Er EAGAIN
The system has no available pseudo-terminal devices.
.El
.Pp
.Fn unlockpt
functions may also fail and set
.Va errno
-for any of the errors specified for the routine
-.Xr fstat 2 .
+for any of the errors specified for the
+.Xr fstat 2
+system call.
.Pp
The
.Fn posix_openpt
function may also fail and set
.Va errno
-for any of the errors specified for the routine
-.Xr open 2 .
+for any of the errors specified for the
+.Xr open 2
+system call.
.Sh SEE ALSO
.Xr open 2 ,
.Xr pty 4 ,