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 Update on Tuesday, May 27th 2025

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 483 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 11 Sept 2019, 11:21 last edited by closx 9 Nov 2019, 11:23
    #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

    J 1 Reply Last reply 11 Sept 2019, 11:27
    0
    • C closx
      11 Sept 2019, 11:21

      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?

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 11 Sept 2019, 11:27 last edited by jsulm 9 Nov 2019, 11:28
      #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 11 Sept 2019, 12:36
      5
      • J jsulm
        11 Sept 2019, 11:27

        @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 11 Sept 2019, 12:36 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

        P 1 Reply Last reply 11 Sept 2019, 12:51
        0
        • C closx
          11 Sept 2019, 12:36

          @jsulm Thank for your answer! That worked.

          P Offline
          P Offline
          Pablo J. Rogina
          wrote on 11 Sept 2019, 12:51 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

          1/4

          11 Sept 2019, 11:21

          • Login

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