#include <sys/types.h>
#include <grp.h>
#include <unistd.h>
#include "setonlygid.h"

int setonlygid(gid_t gid) {
    int rc;

    rc = setgroups(0, NULL);
    if (rc != 0) {
        return rc;
    }
    return setgid(gid);
}


syntax highlighted by Code2HTML, v. 0.9.1