Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

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

    Mobile and Embedded
    3
    4
    243
    Loading More Posts
    • 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
      closx last edited by 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?

      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

      jsulm 1 Reply Last reply Reply Quote 0
      • jsulm
        jsulm Lifetime Qt Champion @closx last edited by jsulm

        @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 Reply Quote 5
        • C
          closx @jsulm last edited by

          @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. Rogina 1 Reply Last reply Reply Quote 0
          • Pablo J. Rogina
            Pablo J. Rogina @closx last edited by

            @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 Reply Quote 0
            • First post
              Last post