Call setgroups(1, &gid) after setting the gid (rather than calling