首页 移动开发 QT     /    Qt编写守护进程

Qt编写守护进程

上传者: feiyangqingyun | 上传时间:2023/12/1 11:49:01 | 文件大小:64KB | 文件类型:zip
Qt编写守护进程
没有任何人敢保证自己写的程序没有任何BUG,尤其是在商业项目中,程序量越大,复杂度越高,出错的概率越大,尤其是现场环境千差万别,和当初本地电脑测试环境很可能不一样,有很多特殊情况没有考虑到,如果需要保证程序7*24小时运行,则需要想一些办法能够让程序死了能够活过来,在嵌入式linux上,大部分会采用看门狗的形式来处理,程序打开看门狗驱动后,定时喂狗,一旦超过规定的时间,则硬件软复位等。
这种方式相对来说比较可靠,如果需要在普通PC机上运行怎办呢?本篇文章提供一个软件实现守护进程的办法,原理就是udp通信,单独写个守护进程程序,专门负责检测主程序是否存在,不存在则启动。
主程序只需要启动live类监听端口,收到hello就回复ok就行。
为了使得兼容任意程序,特意提炼出来共性,增加了多种设置。
1:可设置检测的程序名称。
2:可设置udp通信端口。
3:可设置超时次数。
4:自动记录已重启次数。
5:自动记录最后一次重启时间。
6:是否需要重新刷新桌面。
7:可重置当前重启次数和最后重启时间。
8:自动隐藏的托盘运行或者后台运行。
9:提供界面设置程序名称已经开启和暂停服务。

文件下载

资源详情

[{"title":"(24个子文件64KB)Qt编写守护进程","children":[{"title":"live","children":[{"title":"livedemo","children":[{"title":"applive.cpp <span style='color:#111;'>1.63KB</span>","children":null,"spread":false},{"title":"frmmain.ui <span style='color:#111;'>495B</span>","children":null,"spread":false},{"title":"applive.h <span style='color:#111;'>446B</span>","children":null,"spread":false},{"title":"frmmain.h <span style='color:#111;'>284B</span>","children":null,"spread":false},{"title":"livedemo.pro.user <span style='color:#111;'>23.10KB</span>","children":null,"spread":false},{"title":"frmmain.cpp <span style='color:#111;'>201B</span>","children":null,"spread":false},{"title":"main.cpp <span style='color:#111;'>880B</span>","children":null,"spread":false},{"title":"livedemo.pro <span style='color:#111;'>570B</span>","children":null,"spread":false}],"spread":true},{"title":"live.pro <span style='color:#111;'>82B</span>","children":null,"spread":false},{"title":"snap","children":[{"title":"QQ截图20190302141129.png <span style='color:#111;'>16.29KB</span>","children":null,"spread":false},{"title":"QQ截图20190302141124.png <span style='color:#111;'>10.67KB</span>","children":null,"spread":false},{"title":"QQ截图20190302141147.png <span style='color:#111;'>12.98KB</span>","children":null,"spread":false}],"spread":true},{"title":"livetool","children":[{"title":"trayicon.h <span style='color:#111;'>1.78KB</span>","children":null,"spread":false},{"title":"main.ico <span style='color:#111;'>66.06KB</span>","children":null,"spread":false},{"title":"app.cpp <span style='color:#111;'>2.43KB</span>","children":null,"spread":false},{"title":"frmmain.ui <span style='color:#111;'>2.71KB</span>","children":null,"spread":false},{"title":"main.qrc <span style='color:#111;'>92B</span>","children":null,"spread":false},{"title":"livetool.pro <span style='color:#111;'>595B</span>","children":null,"spread":false},{"title":"frmmain.h <span style='color:#111;'>833B</span>","children":null,"spread":false},{"title":"frmmain.cpp <span style='color:#111;'>5.45KB</span>","children":null,"spread":false},{"title":"main.cpp <span style='color:#111;'>1.27KB</span>","children":null,"spread":false},{"title":"trayicon.cpp <span style='color:#111;'>2.20KB</span>","children":null,"spread":false},{"title":"livetool.pro.user <span style='color:#111;'>29.15KB</span>","children":null,"spread":false},{"title":"app.h <span style='color:#111;'>849B</span>","children":null,"spread":false}],"spread":false}],"spread":true}],"spread":true}]

评论信息

  • 深宫大院:
    一般,还可以吧能起到守护的作用2020-01-08
  • 小岗哥哥:
    代码比较工整,但是守护进程这么写意义不大,核心就是用qprocess去杀、起进程,然后两个demo间用udp通讯,感觉通讯多此一举,可直接在起进程时获取id,记录下来管理起来。2019-11-14

免责申明

【好快吧下载】的资源来自网友分享,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,【好快吧下载】 无法对用户传输的作品、信息、内容的权属或合法性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论 【好快吧下载】 经营者是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。
本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二条之规定,若资源存在侵权或相关问题请联系本站客服人员,8686821#qq.com,请把#换成@,本站将给予最大的支持与配合,做到及时反馈和处理。关于更多版权及免责申明参见 版权及免责申明