Thanks Antonello Your concept in 100% correct but now my problem is that how i can make second process P2 of a process contract CT Pls guide me the what change should i do so that i can get another Process Code is : int activate_template(int parameter) { int tmpl_fd; ctid_t ctid;
if ((tmpl_fd = open64("/system/contract/process/template", O_RDWR)) == -1) { perror("Can't open /system/contract/process/template \n"); return -1; } if (ct_pr_tmpl_set_param(tmpl_fd,parameter) != 0) { perror("Can't set parameter term as inherit and regent"); return -1; } if (ct_tmpl_activate(tmpl_fd) != 0) { perror("Can't activate process contract template"); return -1; } return tmpl_fd; } int adopt_ctid(ctid_t ctid) { char ctl_path[PATH_MAX]; ct_stathdl_t stathdl; int ctl_fd; int pathlen; int stat_fd; pathlen = snprintf(ctl_path, PATH_MAX, CTFS_ROOT "/process/%ld/ctl",ctid); if (pathlen > PATH_MAX) { fprintf(stderr,"Contract ctl file path exceeds maximum path length\n"); return -1; } if ((ctl_fd = open64(ctl_path, O_WRONLY)) < 0) { perror("Couldn't open control file for child contract"); return -1; } /* call ctl_adopt so that the all the event pass to bundle file */ if (ct_ctl_adopt(ctl_fd) != 0) { perror("Couldn't adopt contract"); }else printf("The Contract is adopt successfully \n "); close(ctl_fd); return 0; } int main( ) { int tmpl_fd,tmpl_fd1,tmpl_fd2,tmpl_fd3,tmpl_fd4; pid_t pid,pid_1,pid_2; ctid_t ctid,adopt_ctid; if ((tmpl_fd = activate_template(8)) < 0) { //setting contract with paramater value regent exit(1); } /* * Now that we've set the active template, fork a process to see * a new contract created. */ if ((pid = fork()) < 0) { perror("Can't fork"); exit(1); } if(pid==0){ if(ct_tmpl_clear(tmpl_fd)!=0){ perror("Can't Clear the template"); exit(1); } if((tmpl_fd1 = activate_template(1)) < 0) { //setting contract with paramater value inherit exit(1); } /* Creating the new child contract */ if ((pid_1 = fork()) < 0) { perror("Can't fork"); exit(1); } sleep(2); /* Member process of parent contract abandon*/ }else{ sleep(52); } return 0; } This message posted from opensolaris.org