SETGID(3P)
β¨ SETGID(3P) β the group-ID glow-up β¨
okay bestie, so this one lives in the POSIX Programmer's Manual, and before we go ANY further you need to know the tea:
Heads up fr fr: this page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ β so go check the corresponding Linux manual page for the deets on Linux behavior. Or the interface might just... not be implemented on Linux at all. π
πΈ PROLOG πΈ
okay so real talk, this page comes from the POSIX Programmer's Manual. That means the Linux version of this interface can be different (so go peek at the matching Linux manual page for the actual Linux behavior), or it might not even exist on Linux. Either way, don't come for me, come for the Linux page. π«Ά
π NAME π
setgid β set-group-ID. it's giving "change the group ID of a process" and it's iconic for it.
β¨ SYNOPSIS β¨
#include <unistd.h>
int setgid(gid_t gid);
π DESCRIPTION π
ok so here's the whole vibe. setgid() is gonna do different things depending on whether you have the power or not. main character energy, honestly.
- If the process has appropriate privileges,
setgid()shall set the real group ID, the effective group ID, and the saved set-group-ID of the calling process togid. all three. at once. slay. - If the process does not have appropriate privileges, but
gidis equal to the real group ID or the saved set-group-ID, thensetgid()shall set the effective group ID togid. The real group ID and the saved set-group-ID shall remain unchanged. so only one of the three gets touched, bestie, don't get it twisted. - The
setgid()function shall not affect the supplementary group list in any way. literally none. zero. nada. π - Any supplementary group IDs of the calling process shall remain unchanged. same thing, said twice, because it matters that much. periodt.
π RETURN VALUE π
- If it works? you get
0. clean. gorgeous. ate. π - If it doesn't? you get
-1, anderrnogets set to tell you exactly what went wrong. it's giving "we need to talk".
π ERRORS π
The setgid() function shall fail if:
EINVALβ The value of thegidargument is invalid and is not supported by the implementation. it's just not valid bestie, the implementation said no π«EPERMβ The process does not have appropriate privileges andgiddoes not match the real group ID or the saved set-group-ID. so you don't have the power AND you're not matching either of the two IDs you're allowed to match. double no. π
The following sections are informative. (translation: the next few bits are β¨contextβ¨ not β¨rulesβ¨)
π¦ EXAMPLES π¦
None. empty. a blank canvas. the audacity, honestly. π
πΈ APPLICATION USAGE πΈ
None. also empty. matching energy. π
π RATIONALE π
Refer to the RATIONALE section in setuid(). yeah, this one's just a hand-off. go read that one, it has the lore. iykyk.
β FUTURE DIRECTIONS β
None. the future is... nothing. iconic in its own way.
π₯ SEE ALSO π₯
execgetegid()geteuid()getgid()getuid()setegid()seteuid()setregid()setreuid()setuid()
Also, from the Base Definitions volume of POSIX.1β2017: <sys_types.h> and <unistd.h>. go read those headers, they're right there. π«Ά
π 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 .
and that's the whole page, bestie!! this masterpiece was brought to you by IEEE/The Open Group, 2017 β yeah, 2017, she's been serving this information for a minute and she still ate π β¨πΈπ¦π
π¦ where this page comes from
- alpine 3.22: man-pages-posix 2017a-r0 Β· custom
- alpine 3.23: man-pages-posix 2017a-r0 Β· custom
- alpine 3.24: man-pages-posix 2017a-r0 Β· custom
- arch rolling: man-pages 6.19-1
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages-posix 2017a
- opensuse-leap 16.0: man-pages-posix 2017a-160000.4.1 Β· SUSE-IEEE
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms