I'm trying to do the following:
1. parent application is a simple QT app.
2. from the QT app, I fork a child
3. In the child, I call execve("mplayer", "/home/TTux/test.mpg", 0);
But the call to execve() fails. I can't figure out why.
Below is the code snippet:
QString s = QFileDialog::getOpenFileName("~",
"All Files (*.*)",
"open file dialog",
"Open a file to play"
// save the child's pid in parent's context
this->mplayer = fork();
// in parent process
fprintf(stdout, "Child started successfully");
// in child process
args = (char*) s.ascii();
launch_error = execve("mplayer", args, 0);
fprintf(stdout, "mplayer launch failed: error code %d\n", launch_error);
The output is:
mplayer launch failed: error code -1
error is: No such file or directory
Xlib: unexpected async reply (sequence 0x30c)!
After this the parent's QT window (QMainWindow instance) does remain there, but after a few moment the whole programme hangs and then crashes. I don't know what's wrong with this code, and why is the Xlib printing out a message. The message "Child started successfully" never gets printed.