Browse Source

fix: 修复程序崩溃导致共享内存未回收的问题

- 在程序启动时添加共享内存的附加和分离操作
- 此处理由插件异常导致程序崩溃引发的问题
- 确保在 Linux / Unix 系统中共享内存能够正确回收
zinface 7 months ago
parent
commit
a538f177d0
1 changed files with 6 additions and 0 deletions
  1. 6 0
      src/main.cpp

+ 6 - 0
src/main.cpp

@@ -226,6 +226,12 @@ if ((arguments.size() == 4) && (arguments[2] == QString("-n")))
 }
 #endif
 
+    // 此部分一般由插件异常导致程序崩溃引发
+    // 在 linux / unix 中程序异常结束共享内存不会回收
+    // 参考 https://gitee.com/zinface/infomation-tips/blob/master/src/main.cpp
+    shared.attach();
+    shared.detach();
+
 	//attach成功表示已经存在该内存了,表示当前存在实例
 	if (shared.attach())//共享内存被占用则直接返回
 	{