login_tty()

Updated: April 19, 2023

Prepare for a login in a tty

Synopsis:

#include <unix.h>

int login_tty( int fd );

Arguments:

fd
A file descriptor that you want to use as the controlling terminal for the current process.

Library:

libc

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

Description:

The login_tty() function prepares for a login on the tty fd (which may be a real tty device, or the slave of a pseudo-tty as returned by openpty()) by creating a new session, making fd the controlling terminal for the current process, setting fd to be the standard input, output, and error streams of the current process, and closing fd.

This function fails if ioctl() fails to set fd to the controlling terminal of the current process.

Returns:

0
Success.
-1
An error occurred; errno is set.

Classification:

Unix

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