Main Window closes after execvp() call

xsccmx :

I am learning QT and QT Creator to have experience in working with it. Using Arch Linux with the latest QT libraries.

On a button click function, I am trying to do the following:

std::string name= filename.toStdString();
char *file_path = (char*)name.c_str();

char *myargs[] = {"wormhole", "send", file_path, NULL};
int rc = execvp(myargs[0], myargs); /*This call is the question*/

At the point where the int rc declaration occurs, the mainwindow spawned by this class closes. I am not sure why. Perhaps execvp() is not the right call to make to run the other program?

This call would pass a full file path as an argument to wormhole, it could either exist in /usr/bin or /usr/local/bin, hense the call to execvp()

Ace Figueroa :

The current process is being replaced by the new instantiated process.

The exec() family of functions replaces the current process image with a new process image.

Execvp Linux man page

You probably would want to fork() first, then use execvp().

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=24384&siteId=1