ptsname()

Updated: April 19, 2023

Get the name of a slave pseudo-terminal device

Synopsis:

#include <stdlib.h>

char *ptsname( int filedes );

Arguments:

filedes
The file descriptor for the master pseudo-terminal.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The ptsname() function gets the name of the slave pseudo-terminal device associated with a master pseudo-terminal device.

The ptsname_r() function is a QNX Neutrino function that's a reentrant version of ptsname().

Returns:

A pointer to a NUL-terminated string containing the pathname of the corresponding slave device, or NULL if an error occurred (in QNX Neutrino 7.1 or later, errno is set).

Note: Don't modify the string that this function returns. The pointer might be invalidated or the string overwritten by a subsequent call to ptsname() or if the calling thread is terminated.

Errors:

EBADF
The filedes argument isn't a valid file descriptor.
ENOTTY
The file associated with the filedes argument isn't a master pseudo-terminal device.
EOVERFLOW
The internal buffer is too small to hold the name.

Classification:

POSIX 1003.1

Safety:  
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread No