-
Notifications
You must be signed in to change notification settings - Fork 194
Updated SF-0007 to version 5 #1079
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated SF-0007 to version 5 #1079
Conversation
/// - output: A file descriptor to bind to the subprocess' standard output. | ||
/// - error: A file descriptor to bind to the subprocess' standard error. | ||
/// - Returns: the process identifier for the subprocess. | ||
public static func runDetached( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this in the end just spawning an unstructured Task and calling run
inside that task? If that's the case I would really prefer we don't offer that API and just expect users to construct that unstructured task themselves. This will allow them to still have some ownership of the task and cancel it if needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No there is no unstructured task. This API is not async
at all. It simply spawns the process and returns the PID to you as if you were calling posix_spawn
yourself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Please change the status (on line 6) to
* Status: **2nd Review, Active: Dec 12, 2024...Dec 19, 2024**
@swift-ci please test |
Updated! Thanks! |
@swift-ci please test |
This PR updates the proposal for
SF-0007 Swift Subprocess
to version 5 and added header docs. Here are the changes since version 3:executing
label from.run()
.Subprocess.AsyncBytes
:some AsyncSequence<UInt8, Error>
.typed throws
is ready, we can then update to the actual error type..standardOutput
and.standardError
properties onSubprocess
andCollectedResult
to be non-optional (now they usefatalError
instead).nil
in two cases:.output
/.error
was not set to.redirectToSequence
whenrun()
was called.AsyncSequence
s are reading pipes under the hood, and pipes can only be read once.StandardInputWriter
to be non-sendable.PlatformOptions.additionalAttributeConfigurator
toPlatform.preSpawnAttributeConfigurator
; renamedPlatformOptions.additionalFileAttributeConfigurator
toPlatform.preSpawnFileAttributeConfigurator
.closeWhenDone
parameter labels tocloseAfterSpawningProcess
.Subprocess.Result
toSubprocess.ExecutionResult
.Codable
support toTerminationStatus
andExecutionResult
.TerminationStatus.exit
:.exit
to.exited
..wasUnhandledException
to.isUnhandledException
.Future Direction
:Support Launching Long Running Processes
andProcess Piping
.PlatformOptions
:.closeAllUnknownFileDescriptors
.POSIX_SPAWN_CLOEXEC_DEFAULT
behavior. It is the default value on Darwin.posix_spawn
does not support this flag natively, hence on Linux this behavior is opt-in, and we will fall back to a custom implementation offork/exec
.Subprocess.runDetached
, and others:Hashable
,CustomStringConvertable
andCustomDebugStringConvertible
conformance toSubprocess.Configuration
and friendsSubprocess.Arguments
:Subprocess.Arguments
:public init(_ array: [String])
public init(_ array: [Data])
.Subprocess.CollectedOutputMethod
:.collect
and.collect(upTo:)
Subprocess.PlatformOptions
(all platforms):.default
to using empty initializer.init()
.gid_t
overInt
.PlatformOptions.createProcessGroup
toPlatformOptions.processGroupID
.PlatformOptions.preSpawnAttributeConfigurator
andPlatformOptions.preSpawnFileAttributeConfigurator
intoPlatformOptions.preSpawnProcessConfigurator
to be consistant with other platforms.PlatformOptions
for Linux.PlatformOptions.preSpawnProcessConfigurator
.Arguments
first argument override and non-string support from Windows because Windows does not support either.PlatformOptions
for Windows.Subprocess.send()
withSubprocess.terminate(withExitCode:)
Subprocess.suspend()
Subprocess.resume()
Subprocess.runDetached
:Subprocess.runDetached
as a top level API and sibling to allSubprocess.run
methods. This method allows you to spawn a subprocess WITHOUT needing to wait for it to finish..standardOutput
and.standardError
properties onSubprocess
to beAsyncSequence<Data, any Error>
instead ofAsyncSequence<UInt8, any Error>
.Subprocess.teardown(using:)
to allow developers to gracefully shutdown a subprocess.PlatformOptions.teardownSequence
that will be used to gracefully shutdown the subprocess if the parent task is cancelled.