4 ms·
… unless you intend to exec after forking
by thelopa 5y ago
… unless you intend to exec after forking
- fao_ 5y agoSure, but just use execvp and it's a damn sight safer because you know exactly the state of your child's environment state. You can see this in the CERT C coding guidelines: https://wiki.sei.cmu.edu/confluence/display/c/ENV03-C.+Sanitize+the+environment+when+invoking+external+programs https://wiki.sei.cmu.edu/confluence/display/c/ENV03-C.+Sanit... also ENV02-C comes into effect, as well, if your program is invoked with SOME_INTERNAL_VARIABLE=1 PORT=2000 ./prog then you try to invoke your child with: setenv("SOME_INTERNAL_VARIABLE", "2", 1); (fork blah blah)