tail head cat sleep
QR code linking to this page

Manual Pages  — TCSETSID


tcsetsid – set session ID associated with a controlling terminal



Standard C Library (libc, -lc)


#include <sys/types.h>
#include <termios.h>

tcsetsid(int fd, pid_t pid);


The tcsetsid() function sets associates a session identified by pid with a controlling terminal specified by fd.

This implementation only allows the controlling terminal to be changed by the session leader itself. This implies that pid always has to be equal to the process ID.

It is unsupported to associate with a terminal that already has an associated session. Conversely, it is also unsupported to associate to a terminal when the session is already associated with a different terminal.


If an error occurs, tcsetsid() returns -1 and the global variable errno is set to indicate the error, as follows:
  The fd argument is not a valid file descriptor.
  The file descriptor represented by fd is not a terminal.
  The pid argument is not equal to the session ID of the calling process.
  The calling process is not a session leader.
  The session already has an associated terminal or the terminal already has an associated session.


getsid(2), setsid(2), tcgetpgrp(3), tcgetsid(3)


A tcsetsid() function first appeared in QNX. It does not comply to any standard.

TCSETSID (3) May 4, 2009

tail head cat sleep
QR code linking to this page

Please direct any comments about this manual page service to Ben Bullock. Privacy policy.

A typical Unix /bin or /usr/bin directory contains a hundred different kinds of programs, written by dozens of egotistical programmers, each with its own syntax, operating paradigm, rules of use ... strategies for specifying options, and different sets of constraints.
— The Unix Haters' handbook