I have a basic program that takes some video files, creates a playlist, and then opens the playlist in Totem (video player).
Now, this works just fine but my program itself will not end until the Totem program is closed, which isn't exactly what I want. I want my program to do its things (create playlist and launch it) and then it should close down right after the launching of Totem.
As far as I understand, I need to create a new thread and launch totem in that thread, allowing my main thread to complete and end.
Is this true? If so, how do I go about it? My relevant code is:
1 2 3 4 5 6 7 8 9 10 11 12 13
int main()
{
.........
//save the playlist to a file
playlistFile.open("/tmp/shows-playlist.pls");
playlistFile << playlist;
playlistFile.close();
//launch totem!
system("totem /tmp/shows-playlist.pls");
return 0;
}
Should have mentioned it before but I am programming for Linux.
coder777: it doesn't seam like my main thread is ending though after the system() call. I have a class that outputs a message that it cleaned up after the program.
The end of the program should read out "ssh connection cleaned up" but this does not come up until after I close Totem (the program launched by the system call) so it shows that the main() does not end until the system call is finished.
first argument should be the full path to the program, second argument is an array of cstring arguments (much like the argv element of a C/C++ app that takes arguments)