Created
January 7, 2019 14:15
pipe2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>> module IO::Extensions | |
| extend Fiddle::Importer | |
| dlload Fiddle::Handle::DEFAULT | |
| extern 'int pipe2(int pipefd[2], int flags)' | |
| | |
| def self.pipe_2 flags: | |
| pipefds = [0,0].pack 'i2' | |
| if pipe2(pipefds, flags).zero? | |
| pipefds.unpack('i2').map &IO.method(:for_fd) | |
| else | |
| raise SystemCallError.new Fiddle.last_error | |
| end | |
| end | |
| end | |
=> :pipe_2 | |
>> | |
>> r, w = IO::Extensions.pipe_2 flags: IO::DIRECT | |
=> [#<IO:fd 8>, #<IO:fd 9>] | |
>> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment