Skip to content
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

Refactor Process in preparation for Windows support #6744

Merged
merged 5 commits into from
Oct 13, 2018

Conversation

RX14
Copy link
Contributor

@RX14 RX14 commented Sep 18, 2018

Commits are best read in order, with their descriptions.

@RX14 RX14 added topic:stdlib kind:refactor breaking-change platform:windows Windows support based on the MSVC toolchain / Win32 API labels Sep 18, 2018
@RX14 RX14 force-pushed the feature/process-refactor branch from b8dceed to 3aebf51 Compare September 18, 2018 22:32
src/process.cr Show resolved Hide resolved
@RX14 RX14 requested a review from bcardiff September 19, 2018 10:15
Copy link
Contributor

@ysbaddaden ysbaddaden left a comment

Choose a reason for hiding this comment

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

Good changes overall. Just a few details I'd like to discuss.

src/process.cr Show resolved Hide resolved
src/kernel.cr Outdated Show resolved Hide resolved
@RX14 RX14 force-pushed the feature/process-refactor branch from 3aebf51 to bb6b770 Compare September 19, 2018 21:31
@ysbaddaden
Copy link
Contributor

Let's merge.

@RX14 RX14 added this to the 0.27.0 milestone Oct 1, 2018
@RX14
Copy link
Contributor Author

RX14 commented Oct 1, 2018

I was planning on rebasing the windows part of the process refactor on top of this PR to make 100% sure that this PR was complete, but I'm moving back to university so havent had time :(

I'm fine to merge this, but there's a very small but nonzero chance that there might be more amendments coming.

Copy link
Member

@bcardiff bcardiff left a comment

Choose a reason for hiding this comment

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

I liked the refactors. Rebase & merge when needed.

@@ -147,6 +147,7 @@ class IO::FileDescriptor < IO
end

def reopen(other : IO::FileDescriptor)
return if self.fd == other.fd
Copy link
Contributor

Choose a reason for hiding this comment

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

should this return self?
will this introduce a Nil into the types that can be returned?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for spotting! (this method should probably return nil but thats for another PR.

RX14 added 5 commits October 13, 2018 22:13
Having a single fork_internal method allows all callers to replace it with
Crystal::System::Process.fork more easily.

Also a breaking change as Process.fork no longer uses `with self yield self`.
This is useful when porting to Windows, as Crystal::System::Process.spawn will
take args as an array. This is because Windows's CreateProcess doesn't take an
argument vector.
Previously only errors from LibC.execvp were caught.
This means that Process.exec_internal is always passed an IO::FileDescriptor,
moving non platform-specific code outside of exec_internal and into it's
callers. Also fixes Process.exec crashing with a non-descriptive error when
passed an IO that's not an IO::FileDescriptor. Redirect::Pipe is also disallowed
for exec.
@RX14 RX14 force-pushed the feature/process-refactor branch from bb6b770 to 7a95390 Compare October 13, 2018 21:14
@RX14 RX14 merged commit aad11d4 into crystal-lang:master Oct 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change kind:refactor platform:windows Windows support based on the MSVC toolchain / Win32 API topic:stdlib
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants