#include #include #include /* Important: run this program as root, otherwise, * you won't be able to do setgid */ int main() { int gid, num_procs; unsigned int i; pid_t pid; /* We plan to create 2 processes with group id equal to 1024 */ gid = 1024; num_procs = 2; setgid(gid); while (num_procs--) { pid = fork(); if (!pid) { /* Verify that child has the same gid as parent */ printf("pid = %d, gid = %d\n", getpid(), getgid()); /* Add your own CPU-intensive calculations here */ i = 0xFFFFFFFF; while (i) i--; // add some code to read /proc/getpid()/stat return 0; } } return 0; }