tcsetpgrp(3)

tcsetpgrp3

Set foreground process group id

Usage

#include <unistd.h>

int

tcsetpgrp(int fd, pid_t pgrp_id);

Library

Standard C Library (libc, -lc)

Overview

If the process has a controlling terminal, the tcsetpgrp() function sets the foreground process group ID associated with the terminal device to pgrp_id. The terminal device associated with fd must be the controlling terminal of the calling process and the controlling terminal must be currently associated with the session of the calling process. The value of pgrp_id must be the same as the process group ID of a process in the same session as the calling process.

Return values

The tcsetpgrp() function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error.

Errors

The tcsetpgrp() function will fail if:

[EBADF]

The fd argument is not a valid file descriptor.

[EINVAL]

An invalid value of pgrp_id was specified.

[ENOTTY]

The calling process does not have a controlling terminal, or the file represented by fd is not the controlling terminal, or the controlling terminal is no longer associated with the session of the calling process.

[EPERM]

The pgrp_id argument does not match the process group ID of a process in the same session as the calling process.

Releases

87 releases since FreeBSD 2.0.5-RELEASE; the text changed 43 times.

  1. 2.0.5
  2. 2.1.5–2.2.5
  3. 2.2.6
  4. 2.2.7–3.4
  5. 3.5–3.5.1
  6. 4.0
  7. 4.1–4.2
  8. 4.3–4.4
  9. 4.5–4.11
  10. 5.0–6.3
  11. 6.4
  12. 7.0
  13. 7.1
  14. 7.2
  15. 7.3
  16. 7.4
  17. 8.0
  18. 8.1
  19. 8.2
  20. 8.3
  21. 8.4
  22. 9.0
  23. 9.1
  24. 9.2
  25. 9.3
  26. 10.0
  27. 10.1
  28. 10.2
  29. 10.3
  30. 10.4
  31. 11.0
  32. 11.1
  33. 11.2
  34. 11.3
  35. 11.4
  36. 12.0
  37. 12.1
  38. 12.2
  39. 12.3
  40. 12.4
  41. 13.0–13.1
  42. 13.2
  43. 13.3–14.5
  44. 15.0–16.0

Standards

The tcsetpgrp() function is expected to be compliant with the IEEE Std 1003.1-1988 (“POSIX.1”) specification.

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.