Skip to content

Conversation

@adityaramani
Copy link
Contributor

This change adds a new private method waitIoComplete on the LinuxProcess type.

This method is called internally when the user calls wait for a process - and it tries to give the IO streams some time to clear their buffers.

Internally, this method sets up an AsyncStream down which an item is sent when the vsock connection for either stdout/stderr is terminated.
We get this termination signal when the readability handler for the associated fd fires with a no available data.

Inside the guest - once we are done relaying the IO from the process into the socket connection, we close the socket fd which triggers the above.

All this logic is wrapped around a timeout of 3 seconds, just to ensure the method does not block forever.

Copy link
Contributor

@dcantah dcantah left a comment

Choose a reason for hiding this comment

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

Looks great! Couple comments

Copy link
Contributor

@dcantah dcantah left a comment

Choose a reason for hiding this comment

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

One comment, LGTM!

Signed-off-by: Aditya Ramani <[email protected]>
@adityaramani adityaramani force-pushed the io-wait branch 3 times, most recently from e3b710d to cd642fb Compare June 13, 2025 02:33
Signed-off-by: Aditya Ramani <[email protected]>
@crosbymichael crosbymichael merged commit a4a0cdf into apple:main Jun 13, 2025
2 checks passed
adityaramani added a commit to apple/container that referenced this pull request Jun 16, 2025
Implements a way for the CLI to wait until the IO streams from the
SandboxService have been drained before closing them.

Follows the same pattern as
apple/containerization#110

This change also performs some cleanup in the
`SandboxService.startProcess` method - splitting the code paths to
handle the init process and an exec'd process into two different private
methods to make easier reading

---------

Signed-off-by: Aditya Ramani <[email protected]>
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