Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.
Swift cache-cleanercleanerclideveloper-toolsdisk-cleanupdisk-spaceduplicate-finderhomebrewliquid-glassmac-cleanermacosmacos-appmacos-golden-gatemacos-tahoemacos-tweaksswiftswiftuiterminal-themesuninstalluninstaller
Say who holds an item that stays, and what can be done about it
Țugui Dragoș359e75c9499f
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstringsindex 8c758348..282d74f1 100644--- a/Localization/Peel/Localizable.xcstrings+++ b/Localization/Peel/Localizable.xcstrings@@ -59937,6 +59937,112 @@}}},+ "It is in use by %@, which run as another account or as the system, so neither you nor Peel can quit them. Stop them in Background Items, or with the app’s own uninstaller, then try again." : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Používají ji %@, které běží pod jiným účtem nebo jako systém, takže je nemůžete ukončit vy ani Peel. Zastavte je na stránce Položky na pozadí nebo vlastním odinstalátorem aplikace a zkuste to znovu."+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Es wird gerade von %@ verwendet, ausgeführt unter einem anderen Benutzeraccount oder vom System, daher lassen sie sich weder von dir noch von Peel beenden. Stoppe sie auf der Seite „Hintergrundobjekte“ oder mit dem eigenen Deinstallationsprogramm der App und versuche es dann erneut."+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Está en uso por %@, que se ejecutan con otra cuenta o con la del sistema, así que ni tú ni Peel podéis salir de ellos. Detenlos en la página Ítems en segundo plano, o con el propio desinstalador de la app, antes de volver a intentarlo."+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Il est utilisé par %@, qui s’exécutent sous un autre compte ou sous celui du système, si bien que ni vous ni Peel ne pouvez les quitter. Arrêtez-les sur la page Éléments en arrière-plan, ou avec le programme de désinstallation propre à l’app, puis réessayez."+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "È in uso da %@, in esecuzione con un altro account o come sistema, quindi né tu né Peel potete uscirne. Interrompine l’esecuzione in “Elementi in background” o con il programma di disinstallazione dell’app stessa, poi riprova."+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%@で使用中です。使用しているプログラムはいずれも、別のアカウントまたはシステムとして実行されているため、手動でもPeelからも終了できません。“バックグラウンド項目”またはアプリ独自のアンインストーラで停止してから、やり直してください。"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%@에서 사용 중입니다. 해당 프로그램들은 다른 계정이나 시스템으로 실행되므로, 사용자도 Peel도 종료할 수 없습니다. 백그라운드 항목 페이지나 앱 자체의 제거 프로그램을 사용하여 중단한 다음 다시 시도하십시오."+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Het wordt gebruikt door %@, actief als een andere account of als het systeem, zodat jij en Peel ze niet kunnen stoppen. Stop ze in 'Achtergrondonderdelen' of met het eigen de-installatieprogramma van de app en probeer het opnieuw."+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Jest używane przez: %@. Te programy działają na innym koncie lub jako system, więc ani Ty, ani Peel nie możecie ich zakończyć. Zatrzymaj je na stronie Rzeczy działające w tle albo za pomocą własnego dezinstalatora aplikacji, a potem spróbuj ponownie."+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Está em uso por %@, que são executados por outra conta ou pelo sistema, então nem você nem o Peel podem encerrá-los. Interrompa-os na página Itens em Segundo Plano ou com o desinstalador do próprio app e tente novamente."+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Este utilizat de %@, care rulează în numele altui cont sau al sistemului, așa că nici dvs., nici Peel nu le puteți închide. Opriți‑le în pagina Articole de fundal sau cu programul propriu de dezinstalare al aplicației, apoi încercați din nou."+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Объект используется: %@. Эти программы выполняются от имени другой учетной записи или системы, поэтому ни Вы, ни Peel не можете их завершить. Остановите их в разделе «Фоновые объекты» или с помощью собственной программы удаления приложения, а затем повторите попытку."+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Det används av %@, som körs under ett annat konto eller av systemet, så varken du eller Peel kan avsluta dem. Stoppa dem på sidan Bakgrundsobjekt, eller med appens egen avinstallerare, och försök sedan igen."+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%@ tarafından kullanılıyor. Bu programlar başka bir hesapla veya sistem olarak çalıştıkları için ne siz ne de Peel onlardan çıkabilir. Onları Arka Plan Öğeleri’nde veya uygulamanın kendi yükleme kaldırıcısıyla durdurup yeniden deneyin."+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Його використовують %@, що працюють від імені іншого облікового запису або системи, тож ні ви, ні Peel не можете завершити ці процеси. Зупиніть їх у розділі «Фонові елементи» або власним деінсталятором програми та спробуйте ще раз."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "它正在被“%@”使用,这些程序以另一个账户或系统的身份运行,因此你和Peel都无法退出它们。请在“后台项目”中或使用该App自己的卸载器将其停止,然后重试。"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "它正由%@使用中,由於其以另一個帳號或系統的身分執行,你和Peel都無法將其結束。請在「背景項目」中停止它們,或使用該App自己的解除安裝程式,然後再試一次。"+ }+ }+ }+ },"It is in use by %@, which runs as another account or as the system, so neither you nor Peel can quit it. Stop it in Background Items, or with the app’s own uninstaller, then try again." : {"localizations" : {"cs" : {@@ -60043,108 +60149,214 @@}}},- "It is in use by %@. Quit %@, then try again." : {+ "It is in use by %@. Quit %@, or stop it in Background Items if it has no window, then try again." : {"localizations" : {"cs" : {"stringUnit" : {"state" : "translated",- "value" : "Používá ji %@. Ukončete %@ a zkuste to znovu."+ "value" : "Používá ji %@. Ukončete %@, nebo ho zastavte na stránce Položky na pozadí, pokud nemá žádné okno, a zkuste to znovu."}},"de" : {"stringUnit" : {"state" : "translated",- "value" : "Es wird gerade von %@ verwendet. Beende %@ und versuche es dann erneut."+ "value" : "Es wird gerade von %@ verwendet. Beende %@ oder stoppe es auf der Seite „Hintergrundobjekte“, wenn es kein Fenster hat, und versuche es dann erneut."}},"es" : {"stringUnit" : {"state" : "translated",- "value" : "Está en uso por %@. Sal de %@ antes de volver a intentarlo."+ "value" : "Está en uso por %@. Sal de %@, o detenlo en la página Ítems en segundo plano si no tiene ventana, antes de volver a intentarlo."}},"fr" : {"stringUnit" : {"state" : "translated",- "value" : "Il est utilisé par %@. Quittez %@, puis réessayez."+ "value" : "Il est utilisé par %@. Quittez %@, ou arrêtez-le sur la page Éléments en arrière-plan s’il n’a pas de fenêtre, puis réessayez."}},"it" : {"stringUnit" : {"state" : "translated",- "value" : "È in uso da %@. Esci da %@, poi riprova."+ "value" : "È in uso da %@. Esci da %@, oppure interrompine l’esecuzione in “Elementi in background” se non ha finestre, poi riprova."}},"ja" : {"stringUnit" : {"state" : "translated",- "value" : "%@で使用中です。%@を終了してから、やり直してください。"+ "value" : "%@で使用中です。%@を終了するか、ウインドウがない場合は“バックグラウンド項目”で停止してから、やり直してください。"}},"ko" : {"stringUnit" : {"state" : "translated",- "value" : "%@에서 사용 중입니다. %@을(를) 종료한 다음 다시 시도하십시오."+ "value" : "%@에서 사용 중입니다. %@을(를) 종료하거나, 윈도우가 없는 프로그램이면 백그라운드 항목 페이지에서 중단한 다음 다시 시도하십시오."}},"nl" : {"stringUnit" : {"state" : "translated",- "value" : "Het wordt gebruikt door %@. Stop %@ en probeer het opnieuw."+ "value" : "Het wordt gebruikt door %@. Stop %@, of stop het in 'Achtergrondonderdelen' als het geen venster heeft, en probeer het opnieuw."}},"pl" : {"stringUnit" : {"state" : "translated",- "value" : "Jest używane przez: %@. Zakończ %@, a potem spróbuj ponownie."+ "value" : "Jest używane przez: %@. Zakończ %@ albo zatrzymaj go na stronie Rzeczy działające w tle, jeśli nie ma okna, a potem spróbuj ponownie."}},"pt" : {"stringUnit" : {"state" : "translated",- "value" : "Está em uso por %@. Encerre %@ e tente novamente."+ "value" : "Está em uso por %@. Encerre %@ ou, se ele não tiver janela, interrompa-o na página Itens em Segundo Plano e tente novamente."}},"ro" : {"stringUnit" : {"state" : "translated",- "value" : "Este utilizat de %@. Închideți %@, apoi încercați din nou."+ "value" : "Este utilizat de %@. Închideți %@ sau, dacă nu are ferestre, opriți‑l în pagina Articole de fundal, apoi încercați din nou."}},"ru" : {"stringUnit" : {"state" : "translated",- "value" : "Объект используется: %@. Завершите %@, а затем повторите попытку."+ "value" : "Объект используется: %@. Завершите %@ или, если у программы нет окна, остановите ее в разделе «Фоновые объекты», а затем повторите попытку."}},"sv" : {"stringUnit" : {"state" : "translated",- "value" : "Det används av %@. Avsluta %@ och försök sedan igen."+ "value" : "Det används av %@. Avsluta %@, eller stoppa det på sidan Bakgrundsobjekt om det saknar fönster, och försök sedan igen."}},"tr" : {"stringUnit" : {"state" : "translated",- "value" : "%@ tarafından kullanılıyor. Şu programlardan çıkıp yeniden deneyin: %@."+ "value" : "%@ tarafından kullanılıyor. Şu programdan çıkıp veya penceresi yoksa onu Arka Plan Öğeleri’nde durdurup yeniden deneyin: %@."}},"uk" : {"stringUnit" : {"state" : "translated",- "value" : "Його використовує %@. Завершіть %@ та спробуйте ще раз."+ "value" : "Його використовує %@. Завершіть %@ або зупиніть його в розділі «Фонові елементи», якщо він не має вікна, та спробуйте ще раз."}},"zh-Hans" : {"stringUnit" : {"state" : "translated",- "value" : "它正在被“%@”使用。请退出“%@”,然后重试。"+ "value" : "它正在被“%@”使用。请退出“%@”,如果它没有窗口,则在“后台项目”中将其停止,然后重试。"}},"zh-Hant" : {"stringUnit" : {"state" : "translated",- "value" : "它正由%@使用中。請結束%@,然後再試一次。"+ "value" : "它正由%@使用中。請結束%@,或者如果它沒有視窗,請在「背景項目」中停止它,然後再試一次。"+ }+ }+ }+ },+ "It is in use by %@. Quit %@, or stop them in Background Items if they have no window, then try again." : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Používají ji %@. Ukončete %@, nebo je zastavte na stránce Položky na pozadí, pokud nemají žádné okno, a zkuste to znovu."+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Es wird gerade von %@ verwendet. Beende %@ oder stoppe sie auf der Seite „Hintergrundobjekte“, wenn sie kein Fenster haben, und versuche es dann erneut."+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Está en uso por %@. Sal de %@, o detenlos en la página Ítems en segundo plano si no tienen ventana, antes de volver a intentarlo."+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Il est utilisé par %@. Quittez %@, ou arrêtez-les sur la page Éléments en arrière-plan s’ils n’ont pas de fenêtre, puis réessayez."+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "È in uso da %@. Esci da %@, oppure interrompine l’esecuzione in “Elementi in background” se non hanno finestre, poi riprova."+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%@で使用中です。%@を終了するか、ウインドウがないものは“バックグラウンド項目”で停止してから、やり直してください。"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%@에서 사용 중입니다. %@을(를) 종료하거나, 윈도우가 없는 프로그램은 백그라운드 항목 페이지에서 중단한 다음 다시 시도하십시오."+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Het wordt gebruikt door %@. Stop %@, of stop ze in 'Achtergrondonderdelen' als ze geen venster hebben, en probeer het opnieuw."+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Jest używane przez: %@. Zakończ %@ albo zatrzymaj je na stronie Rzeczy działające w tle, jeśli nie mają okien, a potem spróbuj ponownie."+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Está em uso por %@. Encerre %@ ou, se eles não tiverem janela, interrompa-os na página Itens em Segundo Plano e tente novamente."+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Este utilizat de %@. Închideți %@ sau, dacă nu au ferestre, opriți‑le în pagina Articole de fundal, apoi încercați din nou."+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Объект используется: %@. Завершите %@ или, если у программ нет окон, остановите их в разделе «Фоновые объекты», а затем повторите попытку."+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Det används av %@. Avsluta %@, eller stoppa dem på sidan Bakgrundsobjekt om de saknar fönster, och försök sedan igen."+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%@ tarafından kullanılıyor. Şu programlardan çıkıp veya pencereleri yoksa onları Arka Plan Öğeleri’nde durdurup yeniden deneyin: %@."+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Його використовують %@. Завершіть %@ або зупиніть їх у розділі «Фонові елементи», якщо вони не мають вікон, та спробуйте ще раз."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "它正在被“%@”使用。请退出“%@”,如果它们没有窗口,则在“后台项目”中将其停止,然后重试。"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "它正由%@使用中。請結束%@,或者如果它們沒有視窗,請在「背景項目」中停止它們,然後再試一次。"}}}@@ -198092,6 +198304,112 @@}}},+ "macOS is using it right now, through %@, so it stays where it is." : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Systém macOS ji právě teď používá přes %@, proto zůstane, kde je."+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "macOS verwendet es gerade über %@, daher bleibt es, wo es ist."+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "macOS lo está usando ahora mismo, a través de %@, así que se queda donde está."+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "macOS l’utilise en ce moment via %@ : il reste donc en place."+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "macOS lo sta usando proprio ora, tramite %@, quindi resta dov’è."+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "macOSが%@を通じて現在使用中のため、そのまま残ります。"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "macOS가 지금 %@을(를) 통해 이 항목을 사용하고 있으므로 그대로 남습니다."+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "macOS gebruikt het op dit moment via %@, dus het blijft waar het is."+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "macOS właśnie z tego korzysta za pośrednictwem: %@, więc zostaje to na miejscu."+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "O macOS está usando-o neste momento, por meio de %@, então ele fica onde está."+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "macOS îl utilizează chiar acum, prin %@, așa că el rămâne unde se află."+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "macOS прямо сейчас использует этот объект через %@, поэтому он остается на месте."+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "macOS använder det just nu, via %@, så det stannar där det är."+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "macOS şu anda onu %@ aracılığıyla kullanıyor, bu yüzden öğe olduğu yerde kalır."+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "macOS саме зараз ним користується через %@, тож він лишається на місці."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "macOS现在正在通过“%@”使用它,因此它会留在原处。"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "macOS現在正在透過%@使用它,因此它會留在原處。"+ }+ }+ }+ },"macOS keeps a receipt of the files a package installed. The ones outside the app are listed here only to show them: other software may rely on them. If Peel also found one of them for this app, it appears in the lists above as well, and may be selected there. Forgetting a receipt moves it to the Trash: macOS stops counting the package as installed, and the files stay where they are." : {"localizations" : {"cs" : {diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swiftindex 6a338923..888cc5f9 100644--- a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift+++ b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift@@ -421,11 +421,16 @@ extension TrashFailure.Reason {case .movedWithoutATrace: "in the Trash where macOS didn't say, so only Finder can put it back"case .somethingElseMoved(let name): "something else was at that path; it is in the Trash as \(Output.plain(name))"case .historyUnreadable: "History can't be read"+ case .heldOpen(let processes) where processes.count > 1:+ "in use by \(processes.map(Output.plain).joined(separator: ", ")); quit them, or stop them in Background Items if they have no window, then try again"case .heldOpen(let processes):- "in use by \(processes.map(Output.plain).joined(separator: ", ")); quit \(processes.count == 1 ? "it" : "them") and try again"+ "in use by \(processes.map(Output.plain).joined(separator: ", ")); quit it, or stop it in Background Items if it has no window, then try again"case .peelRunsFromIt: "Peel runs from here; only Remove Peel, in the app's Settings > General, removes Peel"+ case .heldByAnotherAccount(let processes) where processes.count > 1:+ "in use by \(processes.map(Output.plain).joined(separator: ", ")), running as another account or as the system, which Peel can't quit; stop them in Background Items or with the app's own uninstaller, then try again"case .heldByAnotherAccount(let processes):"in use by \(processes.map(Output.plain).joined(separator: ", ")), running as another account or as the system, which Peel can't quit; stop it in Background Items or with the app's own uninstaller, then try again"+ case .inUseByMacOS(let processes): "in use by macOS (\(processes.map(Output.plain).joined(separator: ", ")))"case .failed(let message): Output.plain(message)}}diff --git a/Packages/PeelCore/Sources/PeelCore/Removal/OpenFiles.swift b/Packages/PeelCore/Sources/PeelCore/Removal/OpenFiles.swiftindex 9d54435c..b38d61ea 100644--- a/Packages/PeelCore/Sources/PeelCore/Removal/OpenFiles.swift+++ b/Packages/PeelCore/Sources/PeelCore/Removal/OpenFiles.swift@@ -11,6 +11,8 @@ struct OpenFiles {private typealias File = (names: [String], process: String, pid: pid_t, hold: Hold, isAnotherAccounts: Bool)private let files: [File]+ /// The program each process that holds something runs, by its identifier.+ private let programs: [pid_t: String]/// The program the excluded process runs. Its open files are no hold, but where it runs from is.private let excludedProgram: [String]?@@ -21,16 +23,19 @@ struct OpenFiles {var pids = [pid_t](repeating: 0, count: 8_192)let count = Int(proc_listallpids(&pids, Int32(pids.count * MemoryLayout<pid_t>.size)))var files: [File] = []+ var programs: [pid_t: String] = [:]for pid in pids.prefix(max(count, 0)) where pid > 0 && pid != excluded && !Self.isACopyOfThisProcess(pid) {let path = RunningProgram.path(of: pid)let program = path.flatMap(Self.program(at:)).map { [(path: $0, hold: Hold.runs)] } ?? []let paths = Self.paths(openBy: pid) + programguard !paths.isEmpty else { continue }+ programs[pid] = pathlet process = Self.name(of: pid, program: path)let isAnotherAccounts = kill(pid, 0) != 0 && errno == EPERMfiles += paths.map { (PathComponents.of($0.path), process, pid, $0.hold, isAnotherAccounts) }}self.files = files+ self.programs = programs}/// The programs that hold `url`. An app is code, which loses nothing when it moves, so a program that only reads@@ -48,10 +53,13 @@ struct OpenFiles {let names = PathComponents.of(PathPattern.canonical(url).path(percentEncoded: false))if !lettingItsProgramsRun, let excludedProgram, excludedProgram.starts(with: names) { return .peelRunsFromIt }let holding = holding(url, lettingItsProgramsRun: lettingItsProgramsRun)- let others = Set(holding.filter(\.isAnotherAccounts).map(\.process)).sorted()+ guard !holding.isEmpty else { return nil }+ // macOS's own programs are named only when nothing else holds the item, since nobody quits them.+ let named = holding.filter { !(programs[$0.pid].map(Self.isMacOSsOwn) ?? false) }+ guard !named.isEmpty else { return .inUseByMacOS(by: Set(holding.map(\.process)).sorted()) }+ let others = Set(named.filter(\.isAnotherAccounts).map(\.process)).sorted()if !others.isEmpty { return .heldByAnotherAccount(by: others) }- let holders = Set(holding.map(\.process)).sorted()- return holders.isEmpty ? nil : .heldOpen(by: holders)+ return .heldOpen(by: Set(named.map(\.process)).sorted())}private func holding(_ url: URL, lettingItsProgramsRun: Bool) -> [File] {@@ -99,6 +107,21 @@ struct OpenFiles {return RunningProgram.path(of: pid) == RunningProgram.path(of: getpid())}+ /// Whether the program at `path` is one of macOS's own, which nobody quits: on the sealed system volume or in its+ /// cryptexes, in `/usr/libexec`, `/usr/sbin`, `/sbin` or `/Library/Apple`. An app in the system's Applications+ /// folders and a command in `/bin` or `/usr/bin` are the person's to quit.+ static func isMacOSsOwn(_ path: String) -> Bool {+ let isInside = { (folder: String) in PathComponents.isPath(path, inside: folder) }+ let cryptexes = "/System/Volumes/Preboot/Cryptexes"+ let apps = [+ "/System/Applications", "/System/Library/CoreServices/Applications",+ "/System/Cryptexes/App/System/Applications", "\(cryptexes)/App/System/Applications",+ ]+ guard !apps.contains(where: isInside) else { return false }+ if isInside("/System/Volumes") { return isInside(cryptexes) }+ return ["/System", "/usr/libexec", "/usr/sbin", "/sbin", "/Library/Apple"].contains(where: isInside)+ }+/// The program at `path`, which a process runs, unless it is an app extension: macOS starts and ends those on/// their app's behalf, so the person could not quit one to let its app go.private static func program(at path: String) -> String? {diff --git a/Packages/PeelCore/Sources/PeelCore/Removal/TrashService.swift b/Packages/PeelCore/Sources/PeelCore/Removal/TrashService.swiftindex c15913cd..597015ec 100644--- a/Packages/PeelCore/Sources/PeelCore/Removal/TrashService.swift+++ b/Packages/PeelCore/Sources/PeelCore/Removal/TrashService.swift@@ -87,6 +87,8 @@ public struct TrashFailure: Sendable, Hashable {case peelRunsFromIt/// Processes of another account, root's included, run from it, and neither the person nor Peel may quit them.case heldByAnotherAccount(by: [String])+ /// Only macOS's own programs hold it, and nobody quits those.+ case inUseByMacOS(by: [String])case failed(String)}@@ -106,7 +108,7 @@ extension TrashFailure.Reason {switch self {case .historyUnreadable, .needsHelper: falsecase .guarded, .changedSinceScan, .claimedSinceScan, .lastCopy, .notPermitted, .locked, .movedWithoutATrace,- .somethingElseMoved, .heldOpen, .peelRunsFromIt, .heldByAnotherAccount, .failed: true+ .somethingElseMoved, .heldOpen, .peelRunsFromIt, .heldByAnotherAccount, .inUseByMacOS, .failed: true}}@@ -134,6 +136,7 @@ extension TrashFailure.Reason {case .heldOpen: "held-open"case .peelRunsFromIt: "peel-runs-from-it"case .heldByAnotherAccount: "held-by-another-account"+ case .inUseByMacOS: "in-use-by-macos"case .failed: "failed"}}@@ -142,7 +145,8 @@ extension TrashFailure.Reason {switch self {case .failed(let message): messagecase .somethingElseMoved(let name): name- case .heldOpen(let processes), .heldByAnotherAccount(let processes): processes.joined(separator: "\n")+ case .heldOpen(let processes), .heldByAnotherAccount(let processes), .inUseByMacOS(let processes):+ processes.joined(separator: "\n")default: nil}}@@ -168,6 +172,7 @@ extension TrashFailure.Reason {case "peel-runs-from-it": self = .peelRunsFromItcase "held-by-another-account":self = .heldByAnotherAccount(by: (detail ?? "").split(separator: "\n").map(String.init))+ case "in-use-by-macos": self = .inUseByMacOS(by: (detail ?? "").split(separator: "\n").map(String.init))case "failed": self = .failed(detail ?? "")default: return nil}diff --git a/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swiftindex 40d78fb4..aa76c88a 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift@@ -822,10 +822,11 @@ struct CommandLineTests {#expect(command.resetPrivacy)}- /// A refusal for a program using the item says what to quit before trying again.- @Test func aRefusalForAProgramUsingTheItemSaysWhatToQuit() {- #expect(TrashFailure.Reason.heldOpen(by: ["FigmaAgent"]).summary == "in use by FigmaAgent; quit it and try again")- #expect(TrashFailure.Reason.heldOpen(by: ["FigmaAgent", "java"]).summary == "in use by FigmaAgent, java; quit them and try again")+ @Test func aRefusalForAProgramUsingTheItemSaysWhatToQuitOrStop() {+ #expect(TrashFailure.Reason.heldOpen(by: ["FigmaAgent"]).summary == "in use by FigmaAgent; quit it, or stop it in Background Items if it has no window, then try again")+ #expect(TrashFailure.Reason.heldOpen(by: ["FigmaAgent", "java"]).summary == "in use by FigmaAgent, java; quit them, or stop them in Background Items if they have no window, then try again")+ #expect(TrashFailure.Reason.heldByAnotherAccount(by: ["CtxHelper", "updater"]).summary == "in use by CtxHelper, updater, running as another account or as the system, which Peel can't quit; stop them in Background Items or with the app's own uninstaller, then try again")+ #expect(TrashFailure.Reason.inUseByMacOS(by: ["geod", "appleaccountd"]).summary == "in use by macOS (geod, appleaccountd)")}/// The line printed about the privacy reset after the move, and whether it makes the command fail.diff --git a/Packages/PeelCore/Tests/PeelCoreTests/OpenFilesTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/OpenFilesTests.swiftindex 8c6a1980..4df5e914 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/OpenFilesTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/OpenFilesTests.swift@@ -121,6 +121,62 @@ struct OpenFilesTests {#expect(OpenFiles(excluding: nil).holders(of: directory.url.appending(path: "Example.app")).isEmpty)}+ @Test func namesMacOSWhenOnlyItsOwnProgramsHoldAnItem() throws {+ let directory = try TemporaryDirectory()+ let log = try directory.file("Cache/stats.log")+ let iostat = try Self.macOSProgram(writingTo: log)+ defer { iostat.terminate() }++ let refusal = OpenFiles().refusal(of: log.deletingLastPathComponent(), lettingItsProgramsRun: false)+ #expect(refusal == .inUseByMacOS(by: ["iostat"]))+ }++ @Test func leavesMacOSOutWhileAProgramThatCanQuitHoldsTheItemToo() throws {+ let directory = try TemporaryDirectory()+ let log = try directory.file("Support/stats.log")+ let iostat = try Self.macOSProgram(writingTo: log)+ defer { iostat.terminate() }+ let agent = try directory.runningProgram("Support/agent")+ defer { agent.terminate() }++ let refusal = OpenFiles().refusal(of: log.deletingLastPathComponent(), lettingItsProgramsRun: false)+ #expect(refusal == .heldOpen(by: ["agent"]))+ }++ @Test func knowsMacOSsOwnProgramsByWhereTheyRun() {+ let macOSs = [+ "/usr/libexec/appleaccountd", "/usr/sbin/cfprefsd", "/sbin/launchd",+ "/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/Metadata.framework/Versions/A/Support/mdworker_shared",+ "/System/Library/CoreServices/Dock.app/Contents/MacOS/Dock",+ "/System/Volumes/Preboot/Cryptexes/App/usr/libexec/webpushd",+ "/System/iOSSupport/System/Library/PrivateFrameworks/HomeEnergyDaemon.framework/Support/homeenergyd",+ "/Library/Apple/System/Library/CoreServices/XProtect.app/Contents/XPCServices/XProtectPluginService.xpc/Contents/MacOS/XProtectPluginService",+ ]+ let thePersons = [+ "/System/Volumes/Preboot/Cryptexes/App/System/Applications/Safari.app/Contents/MacOS/Safari",+ "/System/Cryptexes/App/System/Applications/Safari.app/Contents/MacOS/Safari",+ "/System/Applications/Utilities/Console.app/Contents/MacOS/Console",+ "/System/Library/CoreServices/Applications/Archive Utility.app/Contents/MacOS/Archive Utility",+ "/System/Volumes/Data/Applications/Example.app/Contents/MacOS/Example",+ "/usr/bin/tail", "/bin/zsh", "/usr/local/bin/node", "/Applications/Example.app/Contents/MacOS/Example",+ ]++ #expect(macOSs.filter { !OpenFiles.isMacOSsOwn($0) } == [])+ #expect(thePersons.filter(OpenFiles.isMacOSsOwn) == [])+ }++ /// `iostat`, run from where macOS keeps it, writing into `file`, which it holds open until it ends five minutes on.+ private static func macOSProgram(writingTo file: URL) throws -> Process {+ let process = Process()+ process.executableURL = URL(filePath: "/usr/sbin/iostat")+ process.arguments = ["-w", "300", "-c", "2"]+ let output = try FileHandle(forWritingTo: file)+ defer { try? output.close() }+ process.standardOutput = output+ try process.run()+ return process+ }+/// A copy of this process holding only `descriptor`, made by another copy when `madeByACopy`. A copy calls only C:/// another thread may have held a lock of Swift's runtime, and returning into the test would run its cleanup.private static func copyOfThisProcess(diff --git a/Packages/PeelCore/Tests/PeelCoreTests/RefusalLogTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/RefusalLogTests.swiftindex b055fd8e..c56da5ad 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/RefusalLogTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/RefusalLogTests.swift@@ -215,7 +215,8 @@ struct RefusalLogTests {private static let everyReason: [TrashFailure.Reason] = [.guarded(nil), .changedSinceScan, .claimedSinceScan, .lastCopy, .notPermitted, .needsHelper,.movedWithoutATrace, .somethingElseMoved(named: "x 2"), .historyUnreadable,- .heldOpen(by: ["Figma Agent", "java"]), .peelRunsFromIt, .heldByAnotherAccount(by: ["CtxHelper"]), .failed("x"),+ .heldOpen(by: ["Figma Agent", "java"]), .peelRunsFromIt, .heldByAnotherAccount(by: ["CtxHelper"]),+ .inUseByMacOS(by: ["geod", "appleaccountd"]), .failed("x"),] + GuardRefusal.allCases.map { .guarded($0) }/// A record stores its reason as a word, not a sentence, so a later version of Peel can still read it.@@ -224,7 +225,7 @@ struct RefusalLogTests {#expect(Set(reasons.map(\.name)).count == reasons.count)#expect(reasons.allSatisfy { !$0.name.contains(" ") })- #expect(reasons.filter { $0.detail != nil }.count == 4)+ #expect(reasons.filter { $0.detail != nil }.count == 5)}/// History words a refusal from the reason it stored, so every word leads back to its reason, and a word adiff --git a/Packages/PeelCore/Tests/PeelCoreTests/TrashServiceTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/TrashServiceTests.swiftindex d495d17e..da234c1c 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/TrashServiceTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/TrashServiceTests.swift@@ -930,12 +930,13 @@ struct TrashServiceTests {let openFiles = OpenFiles()let unquittable = RunningCopies.current.filter { kill($0.identifier, 0) != 0 && errno == EPERM }for case let (process, bundle?) in unquittable.map({ ($0, $0.bundleURL) }) {- guard case .heldByAnotherAccount(let names) = openFiles.refusal(of: bundle, lettingItsProgramsRun: false)- else {- Issue.record("\(bundle.path(percentEncoded: false)) was refused for no reason of its own")- continue+ let isMacOSs = RunningProgram.path(of: process.identifier).map(OpenFiles.isMacOSsOwn) ?? false+ switch openFiles.refusal(of: bundle, lettingItsProgramsRun: false) {+ case .inUseByMacOS(let names) where isMacOSs, .heldByAnotherAccount(let names) where !isMacOSs:+ #expect(names.contains(OpenFiles.name(of: process.identifier)))+ case let refusal:+ Issue.record("\(bundle.path(percentEncoded: false)) was refused as \(String(describing: refusal))")}- #expect(names.contains(OpenFiles.name(of: process.identifier)))}}diff --git a/Peel/Views/Presentation.swift b/Peel/Views/Presentation.swiftindex 0197aa55..83a08202 100644--- a/Peel/Views/Presentation.swift+++ b/Peel/Views/Presentation.swift@@ -170,11 +170,17 @@ extension TrashFailure.Reason {case .movedWithoutATrace: String(localized: "It is in the Trash, but macOS didn’t say where, so it can only be put back from Finder.")case .somethingElseMoved(let name): String(localized: "Something else was at that path by the time it moved. It is in the Trash as \(name), and Finder can put it back.")case .historyUnreadable: String(localized: "Peel couldn’t read History, and it moves nothing it can’t put back.")+ case .heldOpen(let processes) where processes.count > 1:+ String(localized: "It is in use by \(processes.formatted(.list(type: .and))). Quit \(processes.formatted(.list(type: .and))), or stop them in Background Items if they have no window, then try again.")case .heldOpen(let processes):- String(localized: "It is in use by \(processes.formatted(.list(type: .and))). Quit \(processes.formatted(.list(type: .and))), then try again.")+ String(localized: "It is in use by \(processes.formatted(.list(type: .and))). Quit \(processes.formatted(.list(type: .and))), or stop it in Background Items if it has no window, then try again.")case .peelRunsFromIt: String(localized: "Peel itself runs from here, and only Remove Peel, in Settings > General, removes Peel.")+ case .heldByAnotherAccount(let processes) where processes.count > 1:+ String(localized: "It is in use by \(processes.formatted(.list(type: .and))), which run as another account or as the system, so neither you nor Peel can quit them. Stop them in Background Items, or with the app’s own uninstaller, then try again.")case .heldByAnotherAccount(let processes):String(localized: "It is in use by \(processes.formatted(.list(type: .and))), which runs as another account or as the system, so neither you nor Peel can quit it. Stop it in Background Items, or with the app’s own uninstaller, then try again.")+ case .inUseByMacOS(let processes):+ String(localized: "macOS is using it right now, through \(processes.formatted(.list(type: .and))), so it stays where it is.")case .failed(let message): FixedSentence.translated(message)}}