mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 14:40:12 +01:00
🎨 改进桌面端监控前端界面进程退出钩子
This commit is contained in:
parent
e8641fa682
commit
88c478dc72
1 changed files with 6 additions and 4 deletions
|
|
@ -37,7 +37,10 @@ func HandleSignal() {
|
||||||
Close(false, 1)
|
Close(false, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
var firstRunHookDesktopUIProcJob = true
|
var (
|
||||||
|
firstRunHookDesktopUIProcJob = true
|
||||||
|
noUIProcCount int
|
||||||
|
)
|
||||||
|
|
||||||
func HookDesktopUIProcJob() {
|
func HookDesktopUIProcJob() {
|
||||||
if util.ContainerStd != util.Container || "dev" == util.Mode {
|
if util.ContainerStd != util.Container || "dev" == util.Mode {
|
||||||
|
|
@ -56,7 +59,6 @@ func HookDesktopUIProcJob() {
|
||||||
}
|
}
|
||||||
|
|
||||||
uiProcNames := []string{"siyuan", "electron"}
|
uiProcNames := []string{"siyuan", "electron"}
|
||||||
existUIProc := false
|
|
||||||
util.UIProcessIDs.Range(func(uiProcIDArg, _ interface{}) bool {
|
util.UIProcessIDs.Range(func(uiProcIDArg, _ interface{}) bool {
|
||||||
uiProcID, err := strconv.Atoi(uiProcIDArg.(string))
|
uiProcID, err := strconv.Atoi(uiProcIDArg.(string))
|
||||||
if nil != err {
|
if nil != err {
|
||||||
|
|
@ -77,14 +79,14 @@ func HookDesktopUIProcJob() {
|
||||||
procName := strings.ToLower(proc.Executable())
|
procName := strings.ToLower(proc.Executable())
|
||||||
for _, name := range uiProcNames {
|
for _, name := range uiProcNames {
|
||||||
if strings.Contains(procName, name) {
|
if strings.Contains(procName, name) {
|
||||||
existUIProc = true
|
noUIProcCount++
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
|
||||||
if !existUIProc {
|
if 1 < noUIProcCount {
|
||||||
logging.LogInfof("no active UI proc, exit kernel process now")
|
logging.LogInfof("no active UI proc, exit kernel process now")
|
||||||
Close(false, 1)
|
Close(false, 1)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue