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
Name a build tool's daemon and the command that stops it
Țugui Dragoșcbda76ee37c5
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstringsindex b50411bb..44a21ea9 100644--- a/Localization/Peel/Localizable.xcstrings+++ b/Localization/Peel/Localizable.xcstrings@@ -63033,6 +63033,118 @@}}},+ "It is in use by %@. Run %@, then try again." : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Používá ji %1$@. Spusťte %2$@ a zkuste to znovu."+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Es wird gerade von %1$@ verwendet. Führe %2$@ aus und versuche es dann erneut."+ }+ },+ "en" : {+ "stringUnit" : {+ "state" : "new",+ "value" : "It is in use by %1$@. Run %2$@, then try again."+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Está en uso por %1$@. Ejecuta %2$@ antes de volver a intentarlo."+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Il est utilisé par %1$@. Exécutez %2$@, puis réessayez."+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "È in uso da %1$@. Esegui %2$@, poi riprova."+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@で使用中です。%2$@を実行してから、やり直してください。"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@에서 사용 중입니다. %2$@ 명령을 실행한 다음 다시 시도하십시오."+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Het wordt gebruikt door %1$@. Voer %2$@ uit en probeer het opnieuw."+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Jest używane przez: %1$@. Uruchom %2$@, a potem spróbuj ponownie."+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Está em uso por %1$@. Execute %2$@ e tente novamente."+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Este utilizat de %1$@. Rulați %2$@, apoi încercați din nou."+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Объект используется: %1$@. Выполните %2$@, а затем повторите попытку."+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Det används av %1$@. Kör %2$@ och försök sedan igen."+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ tarafından kullanılıyor. Yeniden denemeden önce şunu çalıştırın: %2$@."+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Його використовує %1$@. Виконайте %2$@ та спробуйте ще раз."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "它正在被“%1$@”使用。请运行%2$@,然后重试。"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "它正由%1$@使用中。請執行%2$@,然後再試一次。"+ }+ }+ }+ },"It is locked. In Finder, choose File > Get Info and deselect Locked, then try again." : {"localizations" : {"cs" : {diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swiftindex 96bb3dce..6a9a8f43 100644--- a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift+++ b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift@@ -452,6 +452,8 @@ extension TrashFailure.Reason {"in use by \(processes.map(Output.plain).joined(separator: ", ")) in another user's account on this Mac; quit them in that account, then try again"case .openForAnotherUser(let processes):"in use by \(processes.map(Output.plain).joined(separator: ", ")) in another user's account on this Mac; quit it in that account, then try again"+ case .heldByABuildTool(let tools):+ "in use by \(tools.map(Output.plain).joined(separator: ", ")); run \(BuildDaemon.stopCommands(for: tools).map { "`\($0)`" }.joined(separator: " and ")), 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/BuildDaemon.swift b/Packages/PeelCore/Sources/PeelCore/Removal/BuildDaemon.swiftnew file mode 100644index 00000000..f9d17a51--- /dev/null+++ b/Packages/PeelCore/Sources/PeelCore/Removal/BuildDaemon.swift@@ -0,0 +1,44 @@+import Foundation++/// A build tool's process that stays after a build to make the next one quicker and keeps the tool's caches open,+/// known by how the tool starts it, with the command the tool documents for stopping it.+public enum BuildDaemon: String, CaseIterable, Sendable {+ case gradle = "Gradle"+ case kotlin = "Kotlin"+ case bazel = "Bazel"+ case mavenDaemon = "mvnd"++ public var stop: String {+ switch self {+ // Gradle's "Gradle Daemon" page: `gradle --stop` stops the daemons of that version of Gradle.+ case .gradle: "gradle --stop"+ // Kotlin's "Compilation and caches in the Kotlin Gradle plugin": the daemon stops with Gradle's.+ case .kotlin: "gradle --stop"+ // Bazel's user manual, `shutdown`.+ case .bazel: "bazel shutdown"+ // mvnd's README, `--stop`.+ case .mavenDaemon: "mvnd --stop"+ }+ }++ /// The commands that stop the daemons of `tools`, each once.+ public static func stopCommands(for tools: [String]) -> [String] {+ var commands: [String] = []+ for command in tools.compactMap({ BuildDaemon(rawValue: $0)?.stop }) where !commands.contains(command) {+ commands.append(command)+ }+ return commands+ }++ /// The daemon a process started with `arguments` is: Gradle and Kotlin name their daemon's main class, mvnd gives+ /// each daemon an `mvnd.id`, and Bazel runs its server from `A-server.jar`.+ static func running(with arguments: [String]) -> BuildDaemon? {+ if arguments.contains("org.gradle.launcher.daemon.bootstrap.GradleDaemon") { return .gradle }+ if arguments.contains("org.jetbrains.kotlin.daemon.KotlinCompileDaemon") { return .kotlin }+ if arguments.contains(where: { $0.hasPrefix("-Dmvnd.id=") }) { return .mavenDaemon }+ let isBazelsServer = arguments.contains { argument in+ argument.split(separator: ":").first?.split(separator: "/").last == "A-server.jar"+ }+ return isBazelsServer ? .bazel : nil+ }+}diff --git a/Packages/PeelCore/Sources/PeelCore/Removal/OpenFiles.swift b/Packages/PeelCore/Sources/PeelCore/Removal/OpenFiles.swiftindex 2243d242..f77cf742 100644--- a/Packages/PeelCore/Sources/PeelCore/Removal/OpenFiles.swift+++ b/Packages/PeelCore/Sources/PeelCore/Removal/OpenFiles.swift@@ -11,7 +11,9 @@ struct OpenFiles {/// Whose a process is: this account's, another user's of this Mac, or the system's, root's and the services'.enum Owner { case thisAccount, anotherUser, system }- private typealias File = (names: [String], process: String, pid: pid_t, hold: Hold, owner: Owner)+ private typealias File = (+ names: [String], process: String, pid: pid_t, hold: Hold, owner: Owner, daemon: BuildDaemon?+ )private let files: [File]/// The program each process that holds something runs, by its identifier.@@ -35,7 +37,10 @@ struct OpenFiles {programs[pid] = pathlet process = Self.name(of: pid, program: path)let owner = kill(pid, 0) != 0 && errno == EPERM ? Self.owner(ofAccount: Self.uid(of: pid)) : .thisAccount- files += paths.map { (PathComponents.of($0.path), process, pid, $0.hold, owner) }+ let isJava = path.map { URL(filePath: $0).lastPathComponent == "java" } == true+ let daemon = owner == .thisAccount && isJava+ ? Self.arguments(of: pid).flatMap(BuildDaemon.running(with:)) : nil+ files += paths.map { (PathComponents.of($0.path), process, pid, $0.hold, owner, daemon) }}self.files = filesself.programs = programs@@ -75,7 +80,7 @@ struct OpenFiles {return Self.refusal(heldBy: holding(url, lettingItsProgramsRun: lettingItsProgramsRun).map { file inHolder(process: file.process, owner: file.owner,- isMacOSsOwn: programs[file.pid].map(Self.isMacOSsOwn) ?? false+ isMacOSsOwn: programs[file.pid].map(Self.isMacOSsOwn) ?? false, daemon: file.daemon)})}@@ -84,6 +89,7 @@ struct OpenFiles {let process: Stringlet owner: Ownerlet isMacOSsOwn: Bool+ var daemon: BuildDaemon? = nil}/// Why an item held by `holders` can't move, each kind of holder with the step that lets it go.@@ -95,9 +101,36 @@ struct OpenFiles {let processes = { (owner: Owner) in Set(named.filter { $0.owner == owner }.map(\.process)).sorted() }if case let users = processes(.anotherUser), !users.isEmpty { return .openForAnotherUser(by: users) }if case let system = processes(.system), !system.isEmpty { return .heldByAnotherAccount(by: system) }+ let daemons = named.compactMap(\.daemon)+ if daemons.count == named.count { return .heldByABuildTool(by: Set(daemons.map(\.rawValue)).sorted()) }return .heldOpen(by: Set(named.map(\.process)).sorted())}+ /// The arguments a process of this account was started with, as `sysctl` gives them (`KERN_PROCARGS2`): their+ /// count, the program's path and the zero bytes after it, then each argument, ended by a zero byte.+ static func arguments(of pid: pid_t) -> [String]? {+ var maximum: Int32 = 0+ var size = MemoryLayout<Int32>.size+ var name = [CTL_KERN, KERN_ARGMAX]+ guard sysctl(&name, u_int(name.count), &maximum, &size, nil, 0) == 0, maximum > 0 else { return nil }+ var buffer = [UInt8](repeating: 0, count: Int(maximum))+ size = buffer.count+ name = [CTL_KERN, KERN_PROCARGS2, pid]+ guard sysctl(&name, u_int(name.count), &buffer, &size, nil, 0) == 0, size > MemoryLayout<Int32>.size+ else { return nil }+ let count = buffer.withUnsafeBytes { $0.loadUnaligned(as: Int32.self) }+ var index = MemoryLayout<Int32>.size+ while index < size, buffer[index] != 0 { index += 1 }+ while index < size, buffer[index] == 0 { index += 1 }+ var arguments: [String] = []+ while arguments.count < count, index < size {+ let end = buffer[index..<size].firstIndex(of: 0) ?? size+ arguments.append(String(decoding: buffer[index..<end], as: UTF8.self))+ index = end + 1+ }+ return arguments+ }+/// A user account starts at 501 on macOS, and the accounts below it are the system's services; `nobody` is -2.static func owner(ofAccount uid: uid_t?) -> Owner {guard let uid, uid >= 501, uid != uid_t(bitPattern: -2) else { return .system }diff --git a/Packages/PeelCore/Sources/PeelCore/Removal/TrashService.swift b/Packages/PeelCore/Sources/PeelCore/Removal/TrashService.swiftindex 5236577f..3d526cc1 100644--- a/Packages/PeelCore/Sources/PeelCore/Removal/TrashService.swift+++ b/Packages/PeelCore/Sources/PeelCore/Removal/TrashService.swift@@ -90,6 +90,8 @@ public struct TrashFailure: Sendable, Hashable {case heldByAnotherAccount(by: [String])/// Another user of this Mac has it open in their own account, where it can be quit.case openForAnotherUser(by: [String])+ /// Only build tools' daemons hold it, which the tools' own commands stop (`BuildDaemon`).+ case heldByABuildTool(by: [String])/// Only macOS's own programs hold it, and nobody quits those.case inUseByMacOS(by: [String])case failed(String)@@ -111,14 +113,14 @@ extension TrashFailure.Reason {switch self {case .historyUnreadable, .needsHelper: falsecase .guarded, .changedSinceScan, .claimedSinceScan, .lastCopy, .notPermitted, .locked, .movedWithoutATrace,- .somethingElseMoved, .heldOpen, .peelRunsFromIt, .heldByAnotherAccount, .openForAnotherUser, .inUseByMacOS,- .failed: true+ .somethingElseMoved, .heldOpen, .peelRunsFromIt, .heldByAnotherAccount, .openForAnotherUser,+ .heldByABuildTool, .inUseByMacOS, .failed: true}}var isHeldByPrograms: Bool {switch self {- case .heldOpen, .heldByAnotherAccount, .openForAnotherUser: true+ case .heldOpen, .heldByAnotherAccount, .openForAnotherUser, .heldByABuildTool: truedefault: false}}@@ -141,6 +143,7 @@ extension TrashFailure.Reason {case .peelRunsFromIt: "peel-runs-from-it"case .heldByAnotherAccount: "held-by-another-account"case .openForAnotherUser: "open-for-another-user"+ case .heldByABuildTool: "held-by-a-build-tool"case .inUseByMacOS: "in-use-by-macos"case .failed: "failed"}@@ -151,7 +154,7 @@ extension TrashFailure.Reason {case .failed(let message): messagecase .somethingElseMoved(let name): namecase .heldOpen(let processes), .heldByAnotherAccount(let processes), .openForAnotherUser(let processes),- .inUseByMacOS(let processes):+ .heldByABuildTool(let processes), .inUseByMacOS(let processes):processes.joined(separator: "\n")default: nil}@@ -180,6 +183,8 @@ extension TrashFailure.Reason {self = .heldByAnotherAccount(by: (detail ?? "").split(separator: "\n").map(String.init))case "open-for-another-user":self = .openForAnotherUser(by: (detail ?? "").split(separator: "\n").map(String.init))+ case "held-by-a-build-tool":+ self = .heldByABuildTool(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 nildiff --git a/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swiftindex d96167cb..f9199cde 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift@@ -955,6 +955,7 @@ struct CommandLineTests {#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)")#expect(TrashFailure.Reason.openForAnotherUser(by: ["Spotify"]).summary == "in use by Spotify in another user's account on this Mac; quit it in that account, then try again")+ #expect(TrashFailure.Reason.heldByABuildTool(by: ["Gradle", "Kotlin"]).summary == "in use by Gradle, Kotlin; run `gradle --stop`, then try again")}/// 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 54e46e98..6c67def1 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/OpenFilesTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/OpenFilesTests.swift@@ -164,6 +164,36 @@ struct OpenFilesTests {#expect(OpenFiles.refusal(heldBy: []) == nil)}+ @Test func aBuildToolsDaemonIsNamedByItsToolWithTheCommandThatStopsIt() throws {+ let directory = try TemporaryDirectory()+ let log = try directory.file("home/.gradle/daemon/9.2/daemon-1.out.log")+ let main = "org.gradle.launcher.daemon.bootstrap.GradleDaemon"+ let daemon = try Self.program("jdk/bin/java", in: directory, arguments: ["-", main, "9.2"], writingTo: log)+ defer { daemon.terminate() }++ let refusal = OpenFiles().refusal(of: log.deletingLastPathComponent(), lettingItsProgramsRun: false)++ #expect(OpenFiles.arguments(of: daemon.processIdentifier)?.suffix(3) == ["-", main, "9.2"])+ #expect(refusal == .heldByABuildTool(by: ["Gradle"]))+ }++ @Test func knowsEachBuildToolsDaemonByHowTheToolStartsIt() {+ let gradle = ["/jdk/bin/java", "-Xmx512m", "-cp", "/x/gradle-launcher-9.2.jar",+ "org.gradle.launcher.daemon.bootstrap.GradleDaemon", "9.2"]+ let kotlin = ["/jdk/bin/java", "-cp", "/x/kotlin-compiler-embeddable.jar",+ "org.jetbrains.kotlin.daemon.KotlinCompileDaemon", "--daemon-runFilesPath=/x"]+ let bazel = ["bazel(project)", "-Xverify:none", "-jar", "/x/install/0123/A-server.jar", "--output_base=/x"]+ let mvnd = ["/jdk/bin/java", "-Dmvnd.id=5a2c", "org.codehaus.plexus.classworlds.launcher.Launcher"]+ let maven = ["/jdk/bin/java", "org.codehaus.plexus.classworlds.launcher.Launcher", "install"]++ #expect(BuildDaemon.running(with: gradle) == .gradle)+ #expect(BuildDaemon.running(with: kotlin) == .kotlin)+ #expect(BuildDaemon.running(with: bazel) == .bazel)+ #expect(BuildDaemon.running(with: mvnd) == .mavenDaemon)+ #expect(BuildDaemon.running(with: maven) == nil)+ #expect(BuildDaemon.allCases.map(\.stop) == ["gradle --stop", "gradle --stop", "bazel shutdown", "mvnd --stop"])+ }+@Test func knowsMacOSsOwnProgramsByWhereTheyRun() {let macOSs = ["/usr/libexec/appleaccountd", "/usr/sbin/cfprefsd", "/sbin/launchd",@@ -186,6 +216,39 @@ struct OpenFilesTests {#expect(thePersons.filter(OpenFiles.isMacOSsOwn) == [])}+ /// A copy of `cat` at `path`, started with `arguments` and holding `file` open for writing as its error output. It+ /// echoes a line before this returns, so macOS has let it run, and reads its input until the test closes it.+ private static func program(+ _ path: String, in directory: borrowing TemporaryDirectory, arguments: [String], writingTo file: URL+ ) throws -> Process {+ let program = directory.url.appending(path: path)+ try FileManager.default.createDirectory(+ at: program.deletingLastPathComponent(), withIntermediateDirectories: true+ )+ try FileManager.default.copyItem(at: URL(filePath: "/bin/cat"), to: program)+ let signing = try Process.run(+ URL(filePath: "/usr/bin/codesign"), arguments: ["--force", "--sign", "-", program.path(percentEncoded: false)]+ )+ signing.waitUntilExit()+ let input = Pipe()+ let output = Pipe()+ let errors = try FileHandle(forWritingTo: file)+ defer { try? errors.close() }+ let line = Data("running\n".utf8)+ try input.fileHandleForWriting.write(contentsOf: line)+ let process = Process()+ process.executableURL = program+ process.arguments = arguments+ process.standardInput = input+ process.standardOutput = output+ process.standardError = errors+ try process.run()+ guard try output.fileHandleForReading.read(upToCount: line.count) == line else {+ throw CocoaError(.executableLoad, userInfo: [NSFilePathErrorKey: program.path])+ }+ return process+ }+/// `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()diff --git a/Packages/PeelCore/Tests/PeelCoreTests/RefusalLogTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/RefusalLogTests.swiftindex 14a00ce1..594b1667 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/RefusalLogTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/RefusalLogTests.swift@@ -216,7 +216,8 @@ struct RefusalLogTests {.guarded(nil), .changedSinceScan, .claimedSinceScan, .lastCopy, .notPermitted, .needsHelper,.movedWithoutATrace, .somethingElseMoved(named: "x 2"), .historyUnreadable,.heldOpen(by: ["Figma Agent", "java"]), .peelRunsFromIt, .heldByAnotherAccount(by: ["CtxHelper"]),- .openForAnotherUser(by: ["Spotify"]), .inUseByMacOS(by: ["geod", "appleaccountd"]), .failed("x"),+ .openForAnotherUser(by: ["Spotify"]), .heldByABuildTool(by: ["Gradle"]),+ .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.@@ -225,7 +226,7 @@ struct RefusalLogTests {#expect(Set(reasons.map(\.name)).count == reasons.count)#expect(reasons.allSatisfy { !$0.name.contains(" ") })- #expect(reasons.filter { $0.detail != nil }.count == 6)+ #expect(reasons.filter { $0.detail != nil }.count == 7)}/// History words a refusal from the reason it stored, so every word leads back to its reason, and a word adiff --git a/Peel/Views/Presentation.swift b/Peel/Views/Presentation.swiftindex 6965314c..e810c5a2 100644--- a/Peel/Views/Presentation.swift+++ b/Peel/Views/Presentation.swift@@ -192,6 +192,8 @@ extension TrashFailure.Reason {String(localized: "It is in use by \(processes.formatted(.list(type: .and))) in another user’s account on this Mac. Quit them in that account, then try again.", bundle: bundle)case .openForAnotherUser(let processes):String(localized: "It is in use by \(processes.formatted(.list(type: .and))) in another user’s account on this Mac. Quit it in that account, then try again.", bundle: bundle)+ case .heldByABuildTool(let tools):+ String(localized: "It is in use by \(tools.formatted(.list(type: .and))). Run \(BuildDaemon.stopCommands(for: tools).map { "`\($0)`" }.formatted(.list(type: .and))), then try again.", bundle: bundle)case .inUseByMacOS(let processes):String(localized: "macOS is using it right now, through \(processes.formatted(.list(type: .and))), so it stays where it is.", bundle: bundle)case .failed(let message): FixedSentence.translated(message, in: bundle)diff --git a/SAFETY.md b/SAFETY.mdindex e34d9814..d435e044 100644--- a/SAFETY.md+++ b/SAFETY.md@@ -162,7 +162,9 @@ it.Right before anything moves, and again once a second while a removal of many items goes on, Peel looks at the filesother programs of yours hold open and at the program each process runs, and leaves where it is any file or folderwith one of them inside, naming the program and how to free the item: quit it, or stop it in Background Items when it-has no window, since launchd starts such a program again.+has no window, since launchd starts such a program again. A build tool's daemon, which stays after a build and keeps+the tool's caches open, is named by its tool with the command that tool documents for stopping it: Gradle's and+Kotlin's stop with `gradle --stop`, Bazel's with `bazel shutdown`, and mvnd's with `mvnd --stop`.Moving a database or a cache from under an agent, a daemon, or a server that is using it would break it. A programof macOS's own, such as a service keeping its cache open, is named as macOS: nobody quits it, so the item stayswhere it is. An app is code, which loses nothing when it moves, so a program that only reads inside it, as Safari