I want to run external program in my app (using qt-2.3), but there is no qprocess class in my qt version.
Is there any idea how to execute external program in qt-2.3?
I want to run external program in my app (using qt-2.3), but there is no qprocess class in my qt version.
Is there any idea how to execute external program in qt-2.3?
You can use standard C calls for that (assuming you have an OS).
Now, I'm using popen() function to run program, but it seemed like I can't stop that running program.
I've tried using pclose(), but it didn't work.
Can u tell me how to stop it?
regards,
pclose() just waits for the application to stop. If you can't convince that application to quit by talking to it through the pipe, you will have to signal it using kill() but for this you need its PID. I don't know if there is a reliable way to get a PID of a child process created with popen(), but you can always use fork+exec combo instead of popen().
Thank you..
I'm using fork+exec now, b'cause when i used popen my program hang up.
But the problem now I still can't kill the child process which I've made.
This is my source code to kill a child process:
pid_t pid;
pid = getpid();
kill(pid,0);
When I ran it after I created child process, my program ended, it seemed that I've also killed the parent process.
Do you have any idea?
really?
so,how can i get pid created by fork and kill it?
thx.
In parent process fork() returns PID of the child process.
Qt Code:
pid_t pid = fork(); if( pid == 0 ) { // child process } else if( pid > 0 ) { // parent process // pid == child's PID } else { // fork failed (parent process) }To copy to clipboard, switch view to plain text mode
Bookmarks