posix_openpt (2)
Leading comments
Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org> All rights reserved. Portions of this software were developed under sponsorship from Snow B.V., the Netherlands. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce t...
NAME
posix_openpt - open a pseudo-terminal deviceLIBRARY
Lb libcSYNOPSIS
In stdlib.h In fcntl.h Ft int Fn posix_openpt int oflagDESCRIPTION
The Fn posix_openpt function allocates a new pseudo-terminal and establishes a connection with its master device. A slave device shall be created in /dev/pts After the pseudo-terminal has been allocated, the slave device should have the proper permissions before it can be used (see grantpt(3)). The name of the slave device can be determined by calling ptsname(3).The file status flags and file access modes of the open file description shall be set according to the value of Fa oflag . Values for Fa oflag are constructed by a bitwise-inclusive OR of flags from the following list, defined in In fcntl.h :
- O_RDWR
- Open for reading and writing.
- O_NOCTTY
- If set Fn posix_openpt shall not cause the terminal device to become the controlling terminal for the process.
- O_CLOEXEC
- Set the close-on-exec flag for the new file descriptor.
The Fn posix_openpt function shall fail when Fa oflag contains other values.
RETURN VALUES
Upon successful completion, the Fn posix_openpt function shall allocate a new pseudo-terminal device and return a non-negative integer representing a file descriptor, which is connected to its master device. Otherwise, -1 shall be returned and errno set to indicate the error.ERRORS
The Fn posix_openpt function shall fail if:- Bq Er ENFILE
- The system file table is full.
- Bq Er EINVAL
- The value of Fa oflag is not valid.
- Bq Er EAGAIN
- Out of pseudo-terminal resources.