Yes the proper way to do that is execve, not by changing global variables in your parent process. https://man7.org/linux/man-pages/man2/execve.2.html
Using setenv is mostly always a hack that relies on a bunch of assumptions that could easily change and be hard to debug.