添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
the effective group ID to the real group ID if groupID is the same as the real group ID of the process. If groupID is not the same as the real group ID of the process, setgid succeeds only if the process belongs to a superuser, in which case it sets the real group ID, effective group ID, and saved set group ID groupID RETURN VALUE setgid returns a if successful and a if unsuccessful. EXAMPLE The following example illustrates the use of setgid to set the effective group ID to the real group ID:

#include <unistd.h>
#include <stdio.h>
main()
   uid_t realGID, effectiveGID;
   realGID = getgid();
   effectiveGID = getegid();
   printf("Real group ID = %dn", (int) realGID);
   printf("Effective group ID = %dn", (int) effectiveGID);
   if (realGID != effectiveGID) {
      if (setgid(realGID) != 0)
         perror("setgid error");
         printf("Effective group ID changed to %d.n", (int) realGID);