Skip to content

Conversation

@jglogan
Copy link
Contributor

@jglogan jglogan commented Sep 24, 2025

  • Makes ProcessIO more generally available.
  • Application.handleProcess(processIO:process:) becomes processIO.handleProcess(process:log:).

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Motivation and Context

This code shouldn't be in the CLI, it should be part of ContainerClient.

Testing

  • Tested locally
  • Added/updated tests
  • Added/updated docs

)
}

public static func handleProcess(io: ProcessIO, process: ClientProcess) async throws -> Int32 {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this becomes an instance function in ProcessIO.swift()

)
}

public func handleProcess(process: ClientProcess, log: Logger) async throws -> Int32 {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

relocated from Application.swift:

  • now an instance function so the io parameter just becomes self
  • was using the log member from Application before, the caller now passes log in

@@ -0,0 +1,381 @@
//===----------------------------------------------------------------------===//
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extracted from ContainerRun in the ContainerCommands target to this file in the ContainerClient target

case table
}

static let signalSet: [Int32] = [
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These were only used by handleProcess so they've also moved to ProcessIO

let stderr: Pipe?
var ioTracker: IoTracker?

static let signalSet: [Int32] = [
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved to here from Application.swift

}
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of this is now down in ProcessIO.swift in ContainerClient.

- Makes ProcessIO more generally available.
- `Application.handleProcess(processIO:process:)` becomes
  `processIO.handleProcess(process:log:)`.
Copy link
Contributor

@katiewasnothere katiewasnothere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The annotations were very helpful, thank you for adding those :)

)
}

public func handleProcess(process: ClientProcess, log: Logger) async throws -> Int32 {
Copy link
Contributor

@dcantah dcantah Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the ProcessIO move, but I'm not as big of a fan about this method on here. To me anything that would call start() or handle process lifecycle makes more sense on the ClientProcess type itself. A run() method on ClientProcess might be a decent naming, as that's essentially what this is. We start + wait + consume IO until completion.

Copy link
Contributor

@dcantah dcantah Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking more about this, not entirely related but, to even be able to get a ClientProcess object we need to pass the io type into bootstrap() or createProcess(), why don't we just have ClientProcess manage the IO type directly? e.g. it can call closeAfterStart() inside the type and not burden the caller with doing it. Additionally, in process.wait() we can do the try await io.wait() just as we do in handleProcess right now. Seems like it'd clean things up a bit.

@jglogan jglogan merged commit 2b07e89 into apple:main Sep 25, 2025
2 checks passed
@jglogan jglogan deleted the processio-refactor branch September 25, 2025 01:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants