在uni的实验室工作中,我必须用一种方法来替换带有下划线的伪代码,以解决涉及“调用循环方法,传入2代表孩子”的任务的方法,我真的不确定如何启动此任务。
if( childProcess >= 0 ) {
if( childProcess == 0 ) {
// this is the child process
printf("New process has id %d,parent id %d\n",getpid(),getppid() );
// call the loop method,passing in 2 to represent child
exit(0);
} else {
// this is the parent process
// call the loop method,passing in 1 to represent parent
}
} else printf("Error when trying to create a new process!\n");
return 0;
}