Running .exe file using QProcess creates hundreds of the same processes
-
I have a problem running phantomjs.exe binary in my QProcess class. Consider this code:
@QString program = "phantomjs.exe";
QProcess *process = new QProcess(this);
process->start(program, QStringList() << "test.js");@test.js file:
@var page = require('webpage').create();
page.open('https://www.google.com.ua/?gws_rd=cr&ei=iP6eUoe9Bsi6ygP18oCADQ#q=ford', function (status) {
if (status !== 'success') {
console.log('Unable to access network');
} else {
var ua = page.evaluate(function () {
return document.getElementById('viewport')[removed];});
console.log(ua);
}
phantom.exit();
});@When I start the app main process loads up and nothing happens after that, just hundreds of other phantomjs.exe are created (checking it in TaskManager) as well as conhost.exe processes.
I tried other exe files, like notepad.exe, and it works just fine. Notepad window appears.
Did you encounter this problem? Please advice.
-
This is not correct:
@
if (status !== 'success') { // line 4!
// should be:
if (status != 'success')
@
In this case, you check if the status != (status = success) so, no this comparison will never be valid! -
Thanks for your reply, but still no luck after changing the code like you said. I think there's something with the binary I run, I'll try to rund bash script to run it, we'll see what's going to happen.
-
Ok, Good luck!
If running a batch, it could be possible that there multiple times the process gets started.
Greetz -
Solution I mentioned before doesn't work either. But when I run custom executable of phantomjs instead of my application everything works fine, really strange.
Maybe you can suggest some other ways of using phantomjs in Qt? As I checked there's no way to build dynamic library out of source.