Mike Frysinger wrote: > On Monday 20 October 2008, Chris Gray wrote: > > On Monday 20 October 2008 19:23, Jamie Lokier wrote: > > > Mike Frysinger wrote: > > > > > @@ -237,9 +237,9 @@ int main(int argc, char **argv) > > > > > send_output("----------------\n", 0, send_flag); > > > > > > > > > > if (outbuf) { > > > > > - pid = fork(); > > > > > + pid = vfork(); > > > > > if (pid < 0) { > > > > > - perror("fork"); > > > > > + perror("vfork"); > > > > > exit(1); > > > > > } > > > > > if (pid) { > > > > > > > > but this one is wrong because the child will call exit() after > > > > writing its log > > > > > > It's ok to call _exit() in a vfork-child, but not exit(). > > > So that should be changed. > > > > > > Writing the log in a vfork-child is dodgy, depending on how it's done. > > > > If vfork returns < 0 then the fork failed and no child process was created, > > n'est-ce pas? So we are executing in the parent. > > read the whole code. there's an exit() in the non-error case. i wasnt > referring to the exit() that happened to be in the patch shown.
Btw, in most cases exit() should not be called in a *fork* child either, let alone *vfork*. It will flush stdio buffers - and they may get flushed by the parent when it exits too. Same for atexit() handlers. Often if there's an exit() in a fork child and the parent too, one of them should be _exit(), and it's usually the child. -- Jamie _______________________________________________ uClinux-dev mailing list uClinux-dev@uclinux.org http://mailman.uclinux.org/mailman/listinfo/uclinux-dev This message was resent by uclinux-dev@uclinux.org To unsubscribe see: http://mailman.uclinux.org/mailman/options/uclinux-dev