某次打開電腦突然發現 Chromium 怎麼樣都打不開,用 terminal 執行後發現以下錯誤訊息:
The profile appears to be in use by another Chromium process (xxxxx)... Chromium has locked the profile so that it doesn't get corrupted (完整的 error message 可以參考這裡)
上網爬了一下發現把 .config/chromium/SingletonLock 刪掉就可以了。
我們可以觀察,當我們把 chromium 打開的時候 .config/chromium/ 底下會多三個檔案:
SingletonCookie SingletonLock SingletonSocket chromium source code 中的 process_singleton_posix.cc
裡面講到 Chromium 會用這三個檔案來管理不同 process 間 profile 的 syncronization
我們去反查上面出現的錯誤訊息的 ID 會發現是 IDS_PROFILE_IN_USE_POSIX 並且在 DisplayProfileInUseError 中被使用,代表下面這個 if 的條件是成立的
if (hostname != net::GetHostName() && !IsChromeProcess(pid)) { // Locked by process on another host. If the user selected to unlock // the profile, try to continue; otherwise quit. if (DisplayProfileInUseError(lock_path_, hostname, pid)) { UnlinkPath(lock_path_); internal::SendRemoteProcessInteractionResultHistogram(PROFILE_UNLOCKED); return PROCESS_NONE; } return PROFILE_IN_USE; } 推測應該是因為前一次不正常的關機使得 SingletonLock 沒有被正確的刪除,而且下一次開機時 PID 也已經找不到對應的 process 或是變成非 Chrome Process。
...