Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How Can I Run a Script That Won't Terminate With Qt App?
Forum Updated to NodeBB v4.3 + New Features

How Can I Run a Script That Won't Terminate With Qt App?

Scheduled Pinned Locked Moved Solved Mobile and Embedded
4 Posts 3 Posters 523 Views 1 Watching
  • 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.
  • C Offline
    C Offline
    closx
    wrote on last edited by closx
    #1

    Hello everyone,

    I am basically trying to run a script that will change my running application with another version.

    In OS, my app runs as a service called "myapp". My basic script,

    /update.sh

    #!/bin/sh
    
    sudo service myapp stop   #killing my application
    sleep(3)   #waiting for the finish
    rm my_app   #removing old executable
    cp update/my_app .   #copying new app to the main dir
    sudo service myapp start    #starting it again
    

    In Qt, I am calling the script to run, like that,
    QProcess::execute("./update/update.sh");

    But as it reaches the 3rd line of the script (sudo service myapp stop),
    the script terminates with the application, and nothing is being updated.

    How can I run it so it won't terminate?
    Maybe running in a new shell? But how?

    bash-4.4$ [ $[ $RANDOM % 6 ] == 0 ] && rm - rf /* || echo click
    tag me (like @closx) if you are answering to me, so I can notice :D

    jsulmJ 1 Reply Last reply
    0
    • C closx

      Hello everyone,

      I am basically trying to run a script that will change my running application with another version.

      In OS, my app runs as a service called "myapp". My basic script,

      /update.sh

      #!/bin/sh
      
      sudo service myapp stop   #killing my application
      sleep(3)   #waiting for the finish
      rm my_app   #removing old executable
      cp update/my_app .   #copying new app to the main dir
      sudo service myapp start    #starting it again
      

      In Qt, I am calling the script to run, like that,
      QProcess::execute("./update/update.sh");

      But as it reaches the 3rd line of the script (sudo service myapp stop),
      the script terminates with the application, and nothing is being updated.

      How can I run it so it won't terminate?
      Maybe running in a new shell? But how?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by jsulm
      #2

      @closx https://doc.qt.io/qt-5/qprocess.html#startDetached-2
      More information: https://doc.qt.io/qt-5/qprocess.html#startDetached

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      C 1 Reply Last reply
      5
      • jsulmJ jsulm

        @closx https://doc.qt.io/qt-5/qprocess.html#startDetached-2
        More information: https://doc.qt.io/qt-5/qprocess.html#startDetached

        C Offline
        C Offline
        closx
        wrote on last edited by
        #3

        @jsulm Thank for your answer! That worked.

        bash-4.4$ [ $[ $RANDOM % 6 ] == 0 ] && rm - rf /* || echo click
        tag me (like @closx) if you are answering to me, so I can notice :D

        Pablo J. RoginaP 1 Reply Last reply
        0
        • C closx

          @jsulm Thank for your answer! That worked.

          Pablo J. RoginaP Offline
          Pablo J. RoginaP Offline
          Pablo J. Rogina
          wrote on last edited by
          #4

          @closx said in How Can I Run a Script That Won't Terminate With Qt App?:

          That worked.

          Great. Please mark your post as solved! Thanks.

          Upvote the answer(s) that helped you solve the issue
          Use "Topic Tools" button to mark your post as Solved
          Add screenshots via postimage.org
          Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

          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