login_tty(3)

login_tty3

Prepare a tty for a new login session

Usage

#include <libutil.h>

int

login_tty(int fd);

Library

System Utilities Library (libutil, -lutil)

Overview

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). 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.

Releases

83 releases since FreeBSD 2.2.2-RELEASE; the text changed 45 times.

  1. 2.2.2–2.2.5
  2. 2.2.6–2.2.8
  3. 2.2.9
  4. 3.0–3.2
  5. 3.3–3.4
  6. 3.5–3.5.1
  7. 4.0
  8. 4.1–4.3
  9. 4.4
  10. 4.5–4.11
  11. 5.0
  12. 5.1–5.2.1
  13. 5.3–6.3
  14. 6.4
  15. 7.0
  16. 7.1
  17. 7.2
  18. 7.3
  19. 7.4
  20. 8.0
  21. 8.1
  22. 8.2
  23. 8.3
  24. 8.4
  25. 9.0
  26. 9.1
  27. 9.2
  28. 9.3
  29. 10.0
  30. 10.1
  31. 10.2
  32. 10.3
  33. 10.4
  34. 11.0
  35. 11.1
  36. 11.2
  37. 11.3
  38. 11.4
  39. 12.0
  40. 12.1
  41. 12.2
  42. 12.3
  43. 12.4
  44. 13.0–13.1
  45. 13.2
  46. 13.3–16.0

History

The function login_tty() first appeared in 4.4BSD.

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.