diff --git a/Package.resolved b/Package.resolved index 9e87893..e61a63f 100644 --- a/Package.resolved +++ b/Package.resolved @@ -23,8 +23,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/getsentry/sentry-cocoa", "state" : { - "revision" : "ac224c437a3070ffe34460137ac8761eddaf2852", - "version" : "8.3.3" + "revision" : "d277532e1c8af813981ba01f591b15bbdd735615", + "version" : "8.8.0" } }, { diff --git a/Package.swift b/Package.swift index 611766d..fc65808 100644 --- a/Package.swift +++ b/Package.swift @@ -18,7 +18,7 @@ let package = Package( .package(url: "https://github.com/antlr/antlr4", branch: "dev"), .package(url: "https://github.com/apple/swift-atomics.git", .upToNextMajor(from: "1.0.0")), .package(url: "https://github.com/nicklockwood/SwiftFormat", from: "0.50.6"), - .package(url: "https://github.com/getsentry/sentry-cocoa", from: "8.3.3"), + .package(url: "https://github.com/getsentry/sentry-cocoa", from: "8.8.0"), .package(url: "https://github.com/cfilipov/TextTable", branch: "master"), .package(url: "https://github.com/sersoft-gmbh/swift-sysctl.git", from: "1.0.0"), ], diff --git a/Sources/tart/PIDLock.swift b/Sources/tart/PIDLock.swift index f65c417..bfe8812 100644 --- a/Sources/tart/PIDLock.swift +++ b/Sources/tart/PIDLock.swift @@ -8,6 +8,11 @@ class PIDLock { init(lockURL: URL) throws { url = lockURL fd = open(lockURL.path, O_RDWR) + if fd == -1 { + let details = Errno(rawValue: CInt(errno)) + + throw RuntimeError.PIDLockFailed("failed to open lock file \(url): \(details)") + } } deinit { diff --git a/Sources/tart/VMDirectory.swift b/Sources/tart/VMDirectory.swift index 4abf572..acaa663 100644 --- a/Sources/tart/VMDirectory.swift +++ b/Sources/tart/VMDirectory.swift @@ -27,7 +27,16 @@ struct VMDirectory: Prunable { } func running() throws -> Bool { - try PIDLock(lockURL: configURL).pid() != 0 + // The most common reason why PIDLock() instantiation fails is a race with "tart delete" (ENOENT), + // which is fine to report as "not running". + // + // The other reasons are unlikely and the cost of getting a false positive is way less than + // the cost of crashing with an exception when calling "tart list" on a busy machine, for example. + guard let lock = try? PIDLock(lockURL: configURL) else { + return false + } + + return try lock.pid() != 0 } static func temporary() throws -> VMDirectory {