I wrote a sample c++ program which forks a linux application (kcalc). I compiled this program using g++ and executed it. The kcalc application is launched. After closing the kcalc application using the quit button I am not getting the terminal. I need to press enter to return to the terminal. But If the kcalc application is called within the program without forking, it will return to the terminal. Could you please help me understand why forked process are not returned to the terminal after closing.
> After closing the kcalc application using the quit button I am not getting the terminal. I need to press enter to return to the terminal
Try enter a command.
1 2 3
if (fork_pid == 0)
int ret = execvp ("kcalc", cmd);
printf("\n\n");//bad indentation, this is outside the if (executes the parent)
Because you didn't wait, kcalc becomes an orphan. That means that you do have a terminal, even with kcalc open