SETGID(3POSIX)
πΈ SETGID(3POSIX) β the POSIX Programmer's Manual, bestie edition πΈ
okay so real talk before we even start: this page lives inside the POSIX Programmer's Manual. The Linux implementation of this interface may differ (so go read the matching Linux manual page for the actual Linux tea β), or the interface may not be implemented on Linux at all. Not me warning you upfront π
β¨ NAME β¨
setgid β set-group-ID. that's it, that's the whole name. short, iconic, does exactly what it says π«Ά
π¦ SYNOPSIS π¦
#include <unistd.h>
int setgid(gid_t gid);
π DESCRIPTION π
Okay so here's the deal. If the process has appropriate privileges, then setgid() shall set the real group ID, the effective group ID, and the saved set-group-ID of the calling process β all three of them, bestie β to gid. Three-for-one, ate that π
If the process does not have appropriate privileges, but gid is equal to the real group ID or the saved set-group-ID, then setgid() shall set the effective group ID to gid. The real group ID and the saved set-group-ID shall remain unchanged. lowkey a limited-edition version of the call but it's still slaying β¨
The setgid() function shall not affect the supplementary group list in any way. periodt.
Any supplementary group IDs of the calling process shall remain unchanged. (yes, same energy as the line above β they really wanted you to get it π)
π RETURN VALUE π
Upon successful completion, 0 is returned. Otherwise, -1 shall be returned and errno set to indicate the error. so basically: 0 = we ate, -1 = we did not eat π
π ERRORS π
The setgid() function shall fail if:
EINVALβ The value of thegidargument is invalid and is not supported by the implementation.EPERMβ The process does not have appropriate privileges andgiddoes not match the real group ID or the saved set-group-ID.
The following sections are informative. (so like, vibe check: read them, but they're not the normative stuff π)
π EXAMPLES π
None.
(genuinely nothing. no examples. we're all just out here raw-dogging the spec π§)
π APPLICATION USAGE π
None.
(also nothing. two empty sections in a row and honestly? iconic minimalism.)
π RATIONALE π
Refer to the RATIONALE section in setuid(). that's it, that's the whole rationale β go read your sibling's homework bestie π
β FUTURE DIRECTIONS β
None.
(no glow-up planned. this function is what it is and we respect it.)
π₯ SEE ALSO π₯
execgetegid()geteuid()getgid()getuid()setegid()seteuid()setregid()setreuid()setuid()
And from 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 .
and that's the whole page, bestie π shoutout to IEEE/The Open Group, 2017 β the year this legend got its stamp. no cap, we're done here. stay privileged, stay valid, and please check your errno π«Άπ
β¨
π¦ 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