#include <unistd.h>
pid_t setsid(void);
setsid() creates a new session if the calling process is not a process group leader. The calling process is the
leader of the new session, the process group leader of the new process group, and has no controlling tty. The process
group ID and session ID of the calling process are set to the PID of the calling process. The calling process will be
the only process in this new process group and in this new session.
#include <unistd.h>
pid_t tcgetpgrp(int fd);
int tcsetpgrp(int fd, pid_t pgrp);
The function tcgetpgrp() returns the process group ID of the foreground process group on the terminal associated to
fd, which must be the controlling terminal of the calling process.
The function tcsetpgrp() makes the process group with process group ID pgrp the foreground process group on the terminal
associated to fd, which must be the controlling terminal of the calling process, and still be associated with its session.
Moreover, pgrp must be a (nonempty) process group belonging to the same session as the calling process.
If tcsetpgrp() is called by a member of a background process group in its session, and the calling process is not blocking
or ignoring SIGTTOU, a SIGTTOU signal is sent to all members of this background process group.