Embedded Linux Simple way to restart QT applications of is based on QT4.8 qws

  • 2020-12-18 02:02:31
  • OfStack

Application software 1 generally has the following business requirements:

When a new version of APP is available, the program needs to perform an update, and when the update is complete (which is mostly in the form of an overwrite), the shutdown is not required, but the application restarts itself.

I looked up some information on the Internet, and it was very complicated. I might as well have created a script to batch my work so simple, fast and brutal.

In the program, you can restart via QT's thread library function, or you can simply call an external script to complete the restart.

[

qApp- > closeAllWindows();
system("/opt/app/restart_app.sh");

]

Here you see, restart_app.sh It's an external script.

The external script contains the following:


#!/bin/sh
killall -9 my_app
echo "restart my_app!"
#close backlight
echo 0 > /sys/class/backlight/backlight/brightness
/opt/app/my_app -qws -nomouse -font wqy-microhei &

When the script is executed, it is first called killall -9 my_app Close the process that is currently in progress and like my app name 1, then turn off the backlight and let LCD go out, and finally, restart app and put app in the background.

This simply completes the app restart action.

conclusion


Related articles: