Q:

bypass system call c++

I was writing a c++ function something like this:
while（true）｛
 function A（)
 system（cmd）
 function B（)
｝

I was doing a system call between two functions and this system call will take a very long time to execute. Is it possible the let it running in the background and bypass it to execute function B at the same time?

A:

On Linux/Unix, system uses a shell for running cmd. This means, you can append an ampersand & to run the command in the background, e.g.
const char cmd[] = "some_command &";
while（true）｛
    functionA();
    system(cmd);
    functionB();
｝

Be aware, that since this is running in a loop while (true) {...}, you might overflow your system with too many background processes.

