C++ question: exec

Published: Updated:
Published: Updated:

Today I found this code extremely confusing.

code with execvp

C/C++ question

What output do you expect? (disregard output from the long_process.sh script)


If you have never dealt with exec() before, then you would wait for 2 lines of "parent done".

Believe me, I ran this code many times today, and it prints "parent done" only once 😱


The exec() function replaces new child process with whatever is in the long_process.sh script. So at line 11 the child fully transforms into another program.

Similar posts

Rate this page