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

Fix #2977: Error calling IO.write with a FIFO #3215

Merged
merged 3 commits into from Nov 26, 2014

Conversation

skliew
Copy link
Contributor

@skliew skliew commented Nov 15, 2014

In MRI, IO.write opens a file with a default mode of File::RDONLY, and does not seek if offset is not given. Fixing these would have rubinius' IO.write behave like MRI's when it's called with a FIFO.

@@ -106,6 +106,30 @@
IO.write(@filename, 'Hëllö'.encode('ISO-8859-1'))
File.binread(@filename).should == "H\xEBll\xF6".force_encoding(Encoding::ASCII_8BIT)
end

platform_is_not :windows do
if `which mkfifo`.chomp != ""
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't want random conditionals like these in specs, it should instead be a proper guard. I'm also not sure if we want to rely on shell executables for this in the first place.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see. I actually saw similar code under spec/ and thought it was the preferred way to do it. I'll remove the conditional and also use the appropriate library functions instead of shell executables.

Thanks for the feedback.

Edit: It seems like there is no way to mkfifo without relying on the system command 'mkfifo'. I guess this justifies why mkfifo is done this way in the spec files I referred to. I found a gem 'mkfifo' but I guess it is also not a good idea to bring it in as a dependency. I'll still replace the call to 'cat' with a proper Ruby file read.

Remove unneeded conditional
Use IO.read instead of `cat`
@brixen
Copy link
Member

brixen commented Nov 26, 2014

@skliew thanks!

brixen added a commit that referenced this pull request Nov 26, 2014
Fix #2977: Error calling IO.write with a FIFO
@brixen brixen merged commit 64d8e17 into rubinius:master Nov 26, 2014
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.

None yet

3 participants