Skip to content

Commit 343694a

Browse files
committed
Discard changes in Subprocess
1 parent 7ca47e0 commit 343694a

11 files changed

+134
-134
lines changed

Sources/_Subprocess/LockedState.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
//===----------------------------------------------------------------------===//
1414

1515
#if canImport(os)
16-
import os
16+
internal import os
1717
#if FOUNDATION_FRAMEWORK && canImport(C.os.lock)
18-
import C.os.lock
18+
internal import C.os.lock
1919
#endif
2020
#elseif canImport(Bionic)
2121
import Bionic

Sources/_Subprocess/Platforms/Subprocess+Darwin.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ import _CShims
3232

3333
// Darwin specific implementation
3434
extension Subprocess.Configuration {
35-
typealias StringOrRawBytes = Subprocess.StringOrRawBytes
35+
internal typealias StringOrRawBytes = Subprocess.StringOrRawBytes
3636

37-
func spawn(
37+
internal func spawn(
3838
withInput input: Subprocess.ExecutionInput,
3939
output: Subprocess.ExecutionOutput,
4040
error: Subprocess.ExecutionOutput
@@ -224,7 +224,7 @@ extension Subprocess {
224224
public var launchRequirementData: Data? = nil
225225
/// An ordered list of steps in order to tear down the child
226226
/// process in case the parent task is cancelled before
227-
/// the child process terminates.
227+
/// the child proces terminates.
228228
/// Always ends in sending a `.kill` signal at the end.
229229
public var teardownSequence: [TeardownStep] = []
230230
/// A closure to configure platform-specific
@@ -288,7 +288,7 @@ extension Subprocess.PlatformOptions: Hashable {
288288
}
289289

290290
extension Subprocess.PlatformOptions : CustomStringConvertible, CustomDebugStringConvertible {
291-
func description(withIndent indent: Int) -> String {
291+
internal func description(withIndent indent: Int) -> String {
292292
let indent = String(repeating: " ", count: indent * 4)
293293
return """
294294
PlatformOptions(
@@ -315,7 +315,7 @@ PlatformOptions(
315315

316316
// MARK: - Process Monitoring
317317
@Sendable
318-
func monitorProcessTermination(
318+
internal func monitorProcessTermination(
319319
forProcessWithIdentifier pid: Subprocess.ProcessIdentifier
320320
) async throws -> Subprocess.TerminationStatus {
321321
return try await withCheckedThrowingContinuation { continuation in

Sources/_Subprocess/Platforms/Subprocess+Linux.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ import _CShims
2222

2323
// Linux specific implementations
2424
extension Subprocess.Configuration {
25-
typealias StringOrRawBytes = Subprocess.StringOrRawBytes
25+
internal typealias StringOrRawBytes = Subprocess.StringOrRawBytes
2626

27-
func spawn(
27+
internal func spawn(
2828
withInput input: Subprocess.ExecutionInput,
2929
output: Subprocess.ExecutionOutput,
3030
error: Subprocess.ExecutionOutput
@@ -123,7 +123,7 @@ extension Subprocess {
123123
public var createSession: Bool = false
124124
/// An ordered list of steps in order to tear down the child
125125
/// process in case the parent task is cancelled before
126-
/// the child process terminates.
126+
/// the child proces terminates.
127127
/// Always ends in sending a `.kill` signal at the end.
128128
public var teardownSequence: [TeardownStep] = []
129129
/// A closure to configure platform-specific
@@ -180,7 +180,7 @@ extension Subprocess.PlatformOptions: Hashable {
180180
}
181181

182182
extension Subprocess.PlatformOptions : CustomStringConvertible, CustomDebugStringConvertible {
183-
func description(withIndent indent: Int) -> String {
183+
internal func description(withIndent indent: Int) -> String {
184184
let indent = String(repeating: " ", count: indent * 4)
185185
return """
186186
PlatformOptions(
@@ -210,7 +210,7 @@ extension String {
210210

211211
// MARK: - Process Monitoring
212212
@Sendable
213-
func monitorProcessTermination(
213+
internal func monitorProcessTermination(
214214
forProcessWithIdentifier pid: Subprocess.ProcessIdentifier
215215
) async throws -> Subprocess.TerminationStatus {
216216
return try await withCheckedThrowingContinuation { continuation in
@@ -262,7 +262,7 @@ private let setup: () = {
262262
default:
263263
fatalError("Unexpected exit status: \(siginfo.si_code)")
264264
}
265-
if let status {
265+
if let status = status {
266266
let pid = siginfo._sifields._sigchld.si_pid
267267
if let existing = continuations.removeValue(forKey: pid),
268268
case .continuation(let c) = existing {

Sources/_Subprocess/Platforms/Subprocess+Unix.swift

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ extension Subprocess {
106106
}
107107
}
108108

109-
func tryTerminate() -> Error? {
109+
internal func tryTerminate() -> Error? {
110110
do {
111111
try self.send(.kill, toProcessGroup: true)
112112
} catch {
@@ -124,9 +124,9 @@ extension Subprocess {
124124

125125
// MARK: - Environment Resolution
126126
extension Subprocess.Environment {
127-
static let pathEnvironmentVariableName = "PATH"
127+
internal static let pathEnvironmentVariableName = "PATH"
128128

129-
func pathValue() -> String? {
129+
internal func pathValue() -> String? {
130130
switch self.config {
131131
case .inherit(let overrides):
132132
// If PATH value exists in overrides, use it
@@ -145,7 +145,7 @@ extension Subprocess.Environment {
145145

146146
// This method follows the standard "create" rule: `env` needs to be
147147
// manually deallocated
148-
func createEnv() -> [UnsafeMutablePointer<CChar>?] {
148+
internal func createEnv() -> [UnsafeMutablePointer<CChar>?] {
149149
func createFullCString(
150150
fromKey keyContainer: Subprocess.StringOrRawBytes,
151151
value valueContainer: Subprocess.StringOrRawBytes
@@ -212,7 +212,7 @@ extension Subprocess.Environment {
212212
extension Subprocess.Arguments {
213213
// This method follows the standard "create" rule: `args` needs to be
214214
// manually deallocated
215-
func createArgs(withExecutablePath executablePath: String) -> [UnsafeMutablePointer<CChar>?] {
215+
internal func createArgs(withExecutablePath executablePath: String) -> [UnsafeMutablePointer<CChar>?] {
216216
var argv: [UnsafeMutablePointer<CChar>?] = self.storage.map { $0.createRawBytes() }
217217
// argv[0] = executable path
218218
if let override = self.executablePathOverride {
@@ -246,7 +246,7 @@ extension Subprocess.ProcessIdentifier : CustomStringConvertible, CustomDebugStr
246246

247247
// MARK: - Executable Searching
248248
extension Subprocess.Executable {
249-
static var defaultSearchPaths: Set<String> {
249+
internal static var defaultSearchPaths: Set<String> {
250250
return Set([
251251
"/usr/bin",
252252
"/bin",
@@ -256,7 +256,7 @@ extension Subprocess.Executable {
256256
])
257257
}
258258

259-
func resolveExecutablePath(withPathValue pathValue: String?) -> String? {
259+
internal func resolveExecutablePath(withPathValue pathValue: String?) -> String? {
260260
switch self.storage {
261261
case .executable(let executableName):
262262
// If the executableName in is already a full path, return it directly
@@ -289,7 +289,7 @@ extension Subprocess.Executable {
289289

290290
// MARK: - Configuration
291291
extension Subprocess.Configuration {
292-
func preSpawn() throws -> (
292+
internal func preSpawn() throws -> (
293293
executablePath: String,
294294
env: [UnsafeMutablePointer<CChar>?],
295295
argv: [UnsafeMutablePointer<CChar>?],
@@ -343,7 +343,7 @@ extension Subprocess.Configuration {
343343
)
344344
}
345345

346-
static func pathAccessible(_ path: String, mode: Int32) -> Bool {
346+
internal static func pathAccessible(_ path: String, mode: Int32) -> Bool {
347347
return path.withCString {
348348
return access($0, mode) == 0
349349
}
@@ -352,18 +352,18 @@ extension Subprocess.Configuration {
352352

353353
// MARK: - FileDescriptor extensions
354354
extension FileDescriptor {
355-
static func openDevNull(
355+
internal static func openDevNull(
356356
withAcessMode mode: FileDescriptor.AccessMode
357357
) throws -> FileDescriptor {
358358
let devnull: FileDescriptor = try .open("/dev/null", mode)
359359
return devnull
360360
}
361361

362-
var platformDescriptor: Subprocess.PlatformFileDescriptor {
362+
internal var platformDescriptor: Subprocess.PlatformFileDescriptor {
363363
return self
364364
}
365365

366-
func readChunk(upToLength maxLength: Int) async throws -> Data? {
366+
internal func readChunk(upToLength maxLength: Int) async throws -> Data? {
367367
return try await withCheckedThrowingContinuation { continuation in
368368
DispatchIO.read(
369369
fromFileDescriptor: self.rawValue,
@@ -383,7 +383,7 @@ extension FileDescriptor {
383383
}
384384
}
385385

386-
func readUntilEOF(upToLength maxLength: Int) async throws -> Data {
386+
internal func readUntilEOF(upToLength maxLength: Int) async throws -> Data {
387387
return try await withCheckedThrowingContinuation { continuation in
388388
let dispatchIO = DispatchIO(
389389
type: .stream,
@@ -404,7 +404,7 @@ extension FileDescriptor {
404404
continuation.resume(throwing: POSIXError(.init(rawValue: error) ?? .ENODEV))
405405
return
406406
}
407-
if let data {
407+
if let data = data {
408408
buffer += Data(data)
409409
}
410410
if done {
@@ -415,7 +415,7 @@ extension FileDescriptor {
415415
}
416416
}
417417

418-
func write<S: Sequence>(_ data: S) async throws where S.Element == UInt8 {
418+
internal func write<S: Sequence>(_ data: S) async throws where S.Element == UInt8 {
419419
try await withCheckedThrowingContinuation { (continuation: CheckedContinuation<Void, Error>) -> Void in
420420
let dispatchData: DispatchData = Array(data).withUnsafeBytes {
421421
return DispatchData(bytes: $0)
@@ -439,13 +439,13 @@ extension FileDescriptor {
439439
}
440440

441441
extension Subprocess {
442-
typealias PlatformFileDescriptor = FileDescriptor
442+
internal typealias PlatformFileDescriptor = FileDescriptor
443443
}
444444

445445
// MARK: - Read Buffer Size
446446
extension Subprocess {
447447
@inline(__always)
448-
static var readBufferSize: Int {
448+
internal static var readBufferSize: Int {
449449
#if canImport(Darwin)
450450
return 16384
451451
#else

0 commit comments

Comments
 (0)