TCSETSID(3)
π TCSETSID(3) π
okay so bestie, this is a page from the Library Functions Manual, and itβs about a lil function that hooks a session up to a controlling terminal. slay, but with rules. π
β¨ NAME β¨
tcsetsid β set session ID associated with a controlling terminal π«Ά
πΈ LIBRARY πΈ
Standard C Library (libc, -lc) π
π¦ SYNOPSIS π¦
#include <termios.h>
int
tcsetsid(int fd, pid_t pid);
π DESCRIPTION π
okay so tcsetsid() associates a session identified by pid with a controlling terminal specified by fd. thatβs the whole vibe. β¨
but hereβs the catch, and itβs kind of a big one: this implementation only allows the controlling terminal to be changed by the session leader itself. which means pid always has to be equal to the process ID. no cap. π
also, it is unsupported to associate with a terminal that already has an associated session. and conversely, it is also unsupported to associate to a terminal when the session is already associated with a different terminal. so yeah, no messy love triangles between sessions and terminals. π
π ERRORS π
if something goes wrong, tcsetsid() returns -1 and the global variable errno is set to indicate the error, as follows:
[EBADF]β thefdargument is not a valid file descriptor. π[ENOTTY]β the file descriptor represented byfdis not a terminal. π[EINVAL]β thepidargument is not equal to the session ID of the calling process. β[EPERM]β the calling process is not a session leader. π«[EPERM]β the session already has an associated terminal, or the terminal already has an associated session. π
π SEE ALSO π
getsid(2), setsid(2), tcgetpgrp(3), tcgetsid(3) π¦
π HISTORY π
a tcsetsid() function first appeared in QNX. it does not comply to any standard. iconic behavior, honestly. π
mwah π β this page is from Debian, dated November 28, 2022, and itβs the TCSETSID(3) manual page. π
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (c) 2009 Ed Schouten <ed@FreeBSD.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms