A shell script test.sh is called from C++ code by the command execl(“/system/bin/sh”,”sh”,”test.sh”)
After the execution of shell script i need to get back the control to C++, but the shell script is just exiting not executing the next instructions in C++ code
Advertisement
Answer
You want to use fork
to create a child process before you exec
:
pid_t pid; if((pid = fork()) == 0) execl("/system/bin/sh","sh","test.sh"); int status; waitpid(pid, &status, 0); // wait for child process, test.sh, to finish