Created
January 7, 2019 14:15
-
-
Save gr33n7007h/a85f0213cfdb9a5a716105c347e9d460 to your computer and use it in GitHub Desktop.
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