TIOCSPGRP(2const)

TIOCSPGRP2const

Process group and session id

Usage

#include <asm/termbits.h>  /* Definition of TIOC* constants */
#include <sys/ioctl.h>

int ioctl(int fd, TIOCGPGRP, pid_t *argp); int ioctl(int fd, TIOCSPGRP, const pid_t *argp); int ioctl(int fd, TIOCGSID, pid_t *argp);

Library

Standard C library (libc, -lc)

Overview

TIOCGPGRP

When successful, equivalent to *argp = tcgetpgrp(fd).

Get the process group ID of the foreground process group on this terminal.

TIOCSPGRP

Equivalent to tcsetpgrp(fd, *argp).

Set the foreground process group ID of this terminal.

TIOCGSID

When successful, equivalent to *argp = tcgetsid(fd).

Get the session ID of the given terminal. This fails with the error ENOTTY if the terminal is not a master pseudoterminal and not our controlling terminal. Strange.

Return value

On success, 0 is returned. On error, -1 is returned, and errno is set to indicate the error.

Errors

ENOTTY

The terminal is not a master pseudoterminal and not our controlling terminal.

EPERM

Insufficient permission.

Releases

2 releases since Debian 13 (Trixie); the text changed 1 time.

  1. 13
  2. Arch

From man-pages 6.19-1 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.