S
sdac
Hi, below is code for a child process, i am trying to give it a group
ID which is +10 on the group ID of the parent process (writing a
simple shell here)
Somehow both print statements show same group ID as if setpgid has no
effect...
if((pid_child2=fork())==0)
{
printf("***hello from c2\n");
printf(" ***c2 gpid used to be %d\n", getpgid(0));
int pgpid = getpgid(0);
setpgid(0,pgpid+10);
printf(" ***c2 gpid was set to %d\n", getpgid(0));
..
..
..
}
SCREEN OUTPUT --->
***hello from c2
***c2 gpid used to be 15946
***c2 gpid was set to 15946
-------------------------
UPDATE:
both setpgid calls are returning -1 and errno EPERM.
Could this be due to the adding of 10 to pgpid ? is that
allowed. The reason i am picking this pgid (x+1) is because i have
two children processos and want them both to have same group ID as
each other, but yet different from there parent.
Any ideas ? Thanks
ID which is +10 on the group ID of the parent process (writing a
simple shell here)
Somehow both print statements show same group ID as if setpgid has no
effect...
if((pid_child2=fork())==0)
{
printf("***hello from c2\n");
printf(" ***c2 gpid used to be %d\n", getpgid(0));
int pgpid = getpgid(0);
setpgid(0,pgpid+10);
printf(" ***c2 gpid was set to %d\n", getpgid(0));
..
..
..
}
SCREEN OUTPUT --->
***hello from c2
***c2 gpid used to be 15946
***c2 gpid was set to 15946
-------------------------
UPDATE:
both setpgid calls are returning -1 and errno EPERM.
Could this be due to the adding of 10 to pgpid ? is that
allowed. The reason i am picking this pgid (x+1) is because i have
two children processos and want them both to have same group ID as
each other, but yet different from there parent.
Any ideas ? Thanks