Hello,
I have a code shown bellow:
I think this should change the child process group but the child process is still in parent process group. Can anyone know what im doing wrong?
Best regards
I have a code shown bellow:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
int main(int argc, char *argv[])
{
int status;
pid_t foo;
pid_t gpid,pid, gpid2, pid2;
pid = getpid();
gpid = getpgid(pid);
foo = fork();
if(foo == 0) {
pid2 = getpid();
gpid2 = getpgid(pid2);
if( setpgid(0,0) < 0) { printf("error\n"); }
exit(0);
}
wait(&status);
return 0;
}
I think this should change the child process group but the child process is still in parent process group. Can anyone know what im doing wrong?
Best regards