---
name: "login_tty"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/login_tty"
---

# login\_tty(3)

prepare a tty for a new login session

## NAME

**login\_tty** – prepare a tty for a new login session

## LIBRARY

System Utilities Library (libutil, -lutil)

## SYNOPSIS

**#include \<libutil.h\>**

*int*\

**login\_tty**(*int fd*);

## DESCRIPTION

The function **login\_tty**() prepares a terminal for a new login session. The file descriptor *fd* passed to **login\_tty**() must be opened for reading and writing on a terminal device. It will be made the controlling terminal for the calling process, after allocating a new session with [setsid(2)](/setsid/2.md). This terminal device will also be made the standard input, standard output, and standard error output of the calling process.

## RETURN VALUES

The **login\_tty**() function returns -1 if it could not make the device referenced by *fd* the controlling terminal of the calling process, and 0 otherwise.

## SEE ALSO

[dup2(2)](/dup2/2.md), [ioctl(2)](/ioctl/2.md), [setsid(2)](/setsid/2.md), [tty(4)](/tty/4.md)

## HISTORY

The function **login\_tty**() first appeared in 4.4BSD.
