Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Running .exe file using QProcess creates hundreds of the same processes
QtWS25 Last Chance

Running .exe file using QProcess creates hundreds of the same processes

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 1.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MaximAlien
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • JeroentjehomeJ Offline
      JeroentjehomeJ Offline
      Jeroentjehome
      wrote on last edited by
      #2

      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!

      Greetz, Jeroen

      1 Reply Last reply
      0
      • M Offline
        M Offline
        MaximAlien
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • JeroentjehomeJ Offline
          JeroentjehomeJ Offline
          Jeroentjehome
          wrote on last edited by
          #4

          Ok, Good luck!
          If running a batch, it could be possible that there multiple times the process gets started.
          Greetz

          Greetz, Jeroen

          1 Reply Last reply
          0
          • M Offline
            M Offline
            MaximAlien
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved