setegid.c
来自「Axis 221 camera embedded programing inte」· C语言 代码 · 共 29 行
C
29 行
#define _GNU_SOURCE#include <unistd.h>#include <stdio.h>#include <errno.h>#include <grp.h>#include <sys/types.h>#include <sys/syscall.h>int setegid(gid_t gid){ int result; if (gid == (gid_t) ~0) { __set_errno (EINVAL); return -1; }#ifdef __NR_setresgid result = setresgid(-1, gid, -1); if (result == -1 && errno == ENOSYS) /* Will also set the saved group ID if egid != gid, * making it impossible to switch back...*/#endif result = setregid(-1, gid); return result;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?