[PATCH] D14014: Checker of proper vfork usage

Devin Coughlin via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 23 14:04:10 PDT 2015


dcoughlin added a comment.

> For example, doing 'x = malloc(4); *x = 0;' in the child process seems fine to me.


I don't think this is necessarily safe. For example, malloc() could end up both modifying memory shared between the child and parent process but only modifying process state for the child, leaving the parent in an inconsistent state.

POSIX (before removing vfork() completely) was pretty brutal about the restrictions in the child:

> ...the behavior is undefined if the process created by vfork() either modifies any data other than a variable of type pid_t used to store the return value from vfork(), or returns from the function in which vfork() was called, or calls any other function before successfully calling _exit() or one of the exec family of functions.





Repository:
  rL LLVM

http://reviews.llvm.org/D14014





More information about the cfe-commits mailing list