---
name: "TIOCSPGRP"
section: "2const"
platform: "linux"
package: "man-pages"
version: "6.19-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/TIOCSPGRP"
---

# TIOCSPGRP(2const)

process group and session ID

## NAME

TIOCGPGRP, TIOCSPGRP, TIOCGSID - process group and session ID

## LIBRARY

Standard C library (*libc*, *-lc*)

## SYNOPSIS

```
#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***);**

## DESCRIPTION

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

## SEE ALSO

[**ioctl**(2)](/ioctl/2.md), [**ioctl\_tty**(2)](/ioctl_tty/2.md), [**tcgetpgrp**(3)](/tcgetpgrp/3.md), [**tcsetpgrp**(3)](/tcsetpgrp/3.md), [**tcgetsid**(3)](/tcgetsid/3.md)
