TCGETPGRP(3POSIX)
π TCGETPGRP(3POSIX) β the POSIX Programmer's Manual, bestie edition π
okay so before we even start, you should know this page lives in the POSIX Programmer's Manual (that's the whole manual name, no cap). Heads up though: the Linux implementation of this interface may differ from what's written here β so if you're on Linux, go check the corresponding Linux manual page for the details of Linux behavior. Or likeβ¦ the interface might not even be implemented on Linux at all. π So vibe check your platform first, fr fr.
β¨ PROLOG β¨
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.
not me repeating myself but this is literally important okay π
π NAME π
tcgetpgrp β get the foreground process group ID
like. it gets you the foreground process group ID. that's the whole job. iconic behavior honestly π
πΈ SYNOPSIS πΈ
#include <unistd.h>
pid_t tcgetpgrp(int fildes);
so you include <unistd.h>, and you hand it a fildes (an int, bestie), and it gives you back a pid_t. simple. clean. slay. π
π¦ DESCRIPTION π¦
The tcgetpgrp() function shall return the value of the process group ID of the foreground process group associated with the terminal. π
If there is no foreground process group, tcgetpgrp() shall return a value greater than 1 that does not match the process group ID of any existing process group. (yes, greater than 1. not 0, not 1. keep up π«Ά)
The tcgetpgrp() function is allowed from a process that is a member of a background process group β so background besties can still call it, periodt. However, the information may be subsequently changed by a process that is a member of a foreground process group. so likeβ¦ the answer you got might be stale by the time you blink. the foreground crew can just rewrite reality on you. it's giving main character energy vs background character energy ngl π
π RETURN VALUE π
Upon successful completion, tcgetpgrp() shall return the value of the process group ID of the foreground process associated with the terminal. π
Otherwise, -1 shall be returned and errno set to indicate the error. (yeah, the classic -1 + errno combo, you know the drill)
π ERRORS π
The tcgetpgrp() function shall fail if:
EBADFβ Thefildesargument is not a valid file descriptor. bestie that is not a file descriptor, what are you doing πENOTTYβ The calling process does not have a controlling terminal, or the file is not the controlling terminal. no terminal, no vibes, no service π«
The following sections are informative. (translation: the juicy part is over, everything below is lore β¨)
π EXAMPLES π
None.
literally none. the examples section said "not today" and went back to sleep π΄
π§ APPLICATION USAGE π§
None.
also none!! two for two on the empty sections, we love a minimalist queen π
π RATIONALE π
None.
none again. the rationale is giving mysterious. iykyk π
β FUTURE DIRECTIONS β
None.
none. the future isβ¦ unspecified. manifesting nothing changes for us π
π₯ SEE ALSO π₯
setsid()setpgid()tcsetpgrp()
The Base Definitions volume of POSIX.1β2017, <sys_types.h>, <unistd.h>
go read those if you want the full cinematic universe. this is the crossover episode π«Ά
π COPYRIGHT π
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
so basically: if this page and the actual Standard disagree, the Standard wins. no contest. the Standard is the referee and it does not take notes from me π
and that's the whole page bestie!! this one came from IEEE/The Open Group, 2017, filed under TCGETPGRP(3POSIX) β go forth and get those foreground process group IDs, you absolute legend πβ¨π¦π
π¦ where this page comes from
- debian bookworm: manpages-posix-dev 2017a-2 Β· Other
- debian trixie: manpages-posix-dev 2017a-2 Β· Other
- ubuntu jammy: manpages-posix-dev 2017a-2 Β· Other
- ubuntu noble: manpages-posix-dev 2017a-2 Β· Other
- ubuntu resolute: manpages-posix-dev 2017a-2build1 Β· Other
- ubuntu stonking: manpages-posix-dev 2017a-2.1 Β· Other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms