TCSETPGRP(3POSIX)
π TCSETPGRP(3POSIX) π
okay bestie, welcome to the POSIX Programmer's Manual β yes this is tcsetpgrp(3POSIX) and yes it's about to be your new hyperfixation π
β¨ PROLOG β¨
This manual page is part of the POSIX Programmer's Manual. Heads up tho β the Linux implementation of this interface may differ (so go consult the corresponding Linux manual page for details on Linux behavior), or the interface may not even be implemented on Linux at all. it's giving "check your local listings" π
πΈ NAME πΈ
tcsetpgrp β set the foreground process group ID. short, sweet, iconic, no notes β¨
π¦ SYNOPSIS π¦
#include <unistd.h>
int tcsetpgrp(int fildes, pid_t pgid_id);
π DESCRIPTION π
So here's the tea π: if the process has a controlling terminal, tcsetpgrp() shall set the foreground process group ID associated with the terminal to pgid_id.
But like, the application has to make sure of some stuff first, no cap:
- the file associated with
fildesis the controlling terminal of the calling process, AND - the controlling terminal is currently associated with the session of the calling process, AND
- the value of
pgid_idmatches a process group ID of a process in the same session as the calling process.
That's the vibe check. all three or it doesn't count π«Ά
Now for the spicy part πΆοΈ: attempts to use tcsetpgrp() from a process which is a member of a background process group on a fildes associated with its controlling terminal shall cause the process group to be sent a SIGTTOU signal. yeah. it will literally come for you.
BUT β if the calling thread is blocking SIGTTOU signals, or the process is ignoring SIGTTOU signals, then the process shall be allowed to perform the operation, and no signal is sent. main character energy: you're immune if you already ghosted the signal π
π₯ RETURN VALUE π₯
- Slayed successfully?
0shall be returned. β¨ - Otherwise?
-1shall be returned anderrnoset to indicate the error. π
π ERRORS π
The tcsetpgrp() function shall fail if:
EBADFβ thefildesargument is not a valid file descriptor. that fd is fake, bestie πEINVALβ this implementation does not support the value in thepgid_idargument. it's giving "we don't do that here"EIOβ the process group of the writing process is orphaned, the calling thread is not blockingSIGTTOU, and the process is not ignoringSIGTTOU. orphaned AND unprotected? rough out here πENOTTYβ the calling process does not have a controlling terminal, or the file is not the controlling terminal, or the controlling terminal is no longer associated with the session of the calling process. three separate ways to not have a terminal, queen of range πEPERMβ the value ofpgid_idis a value supported by the implementation, but does not match the process group ID of a process in the same session as the calling process. so close, yet so far β
The following sections are informative. (translation: cute but not binding π)
π§ EXAMPLES π§
None. nothing. empty. the void. we love a minimalist π
π APPLICATION USAGE π
None. again. iconic silence β¨
π RATIONALE π
None. it simply has no thoughts, head empty π¦
π FUTURE DIRECTIONS π
None. the future is unwritten and also this page says nothing about it π
π«Ά SEE ALSO π«Ά
tcgetpgrp()- The Base Definitions volume of POSIX.1β2017,
<sys_types.h>,<unistd.h>
π 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 .
fr fr, that's the whole legal bit, verbatim, do not touch π
IEEE/The Open Group β’ 2017 β’ TCSETPGRP(3POSIX)
okay that's the page bestie, mwah, go set that foreground process group, ily π«Άβ¨π
π¦ 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