jeudi 26 février 2015

forking but not exiting


It is normal for the child in a fork() to call exec() or _exit().


Are there any realistic scenarios where the child might return from the function that called fork() instead?



void foo() {
pid_t pid = fork();
if(pid == 0) {
...
return; //<-- the child is going to unwind the cloned call stack
}
...


So what legitimate uses are there for a forked child returning? Are there any standards that govern this?





Aucun commentaire:

Enregistrer un commentaire