I have a comprension question about this code that I am currently studying: this function is used in a C Shell implementation to execute piped commands. I can't understand how the person who wrote it got to know how many pipes to close (why is the limit 2*com- 2
)?
for(i = 0; i < 2*com - 2; i++) close(pip[i]);
for(i = 0; i < com; ++i) {
waitpid(pid, &status, WUNTRACED);