bsriniv@cadev1.intel.com (Bhaskar Srinivasan ~) (05/22/91)
Hi, I have a problem with setpgid/setpgrp call on Aixv3.1. When I run the following code on SunOSV4.0.2, I am able to change the process group id of the process that exec`ed. On AixV3.1, I get an error from the setpgid call, "setpgid: Not owner" Does anybody know what is going on ? Any help is appreciated. Thanx Bhaskar ------------------------------------------------------------------------ #include <stdio.h> #include <signal.h> #include <sys/wait.h> #include <sys/time.h> #include <sys/resource.h> main() { char *av[6]; int i, ac; int pg = 10000; int newpg; int sig, child; void donechild(); for(i=0; i<32; i++) signal(i, SIG_IGN); signal(SIGCHLD, donechild); signal(SIGINT, SIG_DFL); signal(SIGQUIT, SIG_DFL); av[0] = "csh"; av[1] = "-c"; av[2] = "tbat"; av[3] = 0; if(child = fork()) { for(;;) { fscanf(stdin, "%d", &sig); if (killpg(pg, sig) < 0) perror("killpg"); printf("signal %d\n", sig); } } else { for(i=0; i<32; i++) signal(i, SIG_IGN); signal(SIGINT, SIG_DFL); signal(SIGQUIT, SIG_DFL); /* if(setpgrp(0, pg) < 0) */ if(setpgid(0, pg) < 0) perror("setpgid"); printf("starting\n"); execvp(av[0], av); } } void donechild() { int pid; /* union wait status; */ int status; struct rusage ruse; printf("entering donechild\n"); while((pid = wait3(&status, WNOHANG, &ruse)) > 0) { if (WIFSTOPPED(status)) printf("stopped child\n"); else { printf("donechild\n"); exit(0); } } }