I wouldn't criticize anyone for posting code snippets for educational purposes without confounding the learner with all of the error checking. Pedagogy vs pedantry.
if (pid < 0) { /* TODO: handle error */ }
Reading the actual code I doubt it's just an oversight, the coding style used seems to lend strongly towards not thinking an error is possible: if ((pid = fork()) == 0)
{ //Child
longTask();
} else {
children[i] = pid;
}So does every tutorial which doesn't check the return from printf or check for errors from cout. Did you notice that the parent and child are both writing to the same file descriptor? Maybe the writer should add some words and tests in his code about the inherent race condition there. A true pedant would push this even further and teach their audience how to eliminate this problem with cross process mutexes or semaphores. Better be sure to check the error codes on those calls too.
I know arguing with a pedant is like wrestling with a pig, but honestly I'm more offended by the "#define N 2" than by the lack of error checking.