c++ - execve : convert execve call to fork -
i have execve system call overlay curernt program one. code works fine requirement change execve system call fork system call. trying below:
pid_t child_pid; child_pid = fork(); if(child_pid == 0) { if (-1 == execve(...)) //normal previous execve call { ............. } } else { //fork parent process exit(0); }
i not sure when replacing execve system call fork things should take care. in child process calling existing execve call let original flow maintained (as if without fork) should parent - should exit or need wait child process exit/die. execve call overlays current process new 1 there no question of parent / child process.
if exit status of child needs known, or if there operation performed after child process exits, call wait()
in parent.
if there no need either of above, can exit parent process. orphaned process re-parented init
, , hence have no adverse effects.
Comments
Post a Comment