mardi 12 février 2019

Will std::system execute even after parent process has exited?

I am running a C++ console application in an embedded linux environment. I want to run a std::system command just like this. I have taken tar for an example.

int main(int argc, char *argv[]) {
    std::system("tar xvzf /path/to/some/file.tar.gz");
    exit 0;
}

Question:
If I exit the application right after the tar command like above, will the tar command continue to execute?
I understand that it depends a bit on how tar is implemented itself. But lets say tar doesn't work after parent process exits (considering worst case scenario), is there a way I can run the command std::system command safely in background and exit my app trusting that it will complete its job after my app or parent process has exited?

Aucun commentaire:

Enregistrer un commentaire