Class: AngryShell::Shell::IPCState
- Inherits:
-
Struct
- Object
- Struct
- AngryShell::Shell::IPCState
- Defined in:
- lib/angry_shell.rb
Instance Attribute Summary collapse
-
#error ⇒ Object
(also: #stderr)
Returns the value of attribute error.
-
#exception ⇒ Object
Returns the value of attribute exception.
-
#read ⇒ Object
(also: #stdout)
Returns the value of attribute read.
-
#write ⇒ Object
Returns the value of attribute write.
Instance Method Summary collapse
- #before_fork! ⇒ Object
- #child_after_fork! ⇒ Object
- #close_all ⇒ Object
-
#initialize ⇒ IPCState
constructor
A new instance of IPCState.
- #parent_after_fork! ⇒ Object
Constructor Details
#initialize ⇒ IPCState
Returns a new instance of IPCState.
103 104 105 |
# File 'lib/angry_shell.rb', line 103 def initialize super(IO.pipe, IO.pipe, IO.pipe, IO.pipe) end |
Instance Attribute Details
#error ⇒ Object Also known as: stderr
Returns the value of attribute error
102 103 104 |
# File 'lib/angry_shell.rb', line 102 def error @error end |
#exception ⇒ Object
Returns the value of attribute exception
102 103 104 |
# File 'lib/angry_shell.rb', line 102 def exception @exception end |
#read ⇒ Object Also known as: stdout
Returns the value of attribute read
102 103 104 |
# File 'lib/angry_shell.rb', line 102 def read @read end |
#write ⇒ Object
Returns the value of attribute write
102 103 104 |
# File 'lib/angry_shell.rb', line 102 def write @write end |
Instance Method Details
#before_fork! ⇒ Object
107 108 109 |
# File 'lib/angry_shell.rb', line 107 def before_fork! exception.last.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) end |
#child_after_fork! ⇒ Object
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/angry_shell.rb', line 111 def child_after_fork! write.last.close STDIN.reopen write.first write.first.close self.write = STDIN read.first.close STDOUT.reopen read.last read.last.close self.read = STDOUT error.first.close STDERR.reopen error.last error.last.close self.error = STDERR exception.first.close self.exception = exception.last STDOUT.sync = STDERR.sync = true end |
#close_all ⇒ Object
148 149 150 |
# File 'lib/angry_shell.rb', line 148 def close_all [ read, write, error, exception ].flatten.compact.each {|fd| fd.close unless fd.closed?} end |
#parent_after_fork! ⇒ Object
136 137 138 139 140 141 142 143 |
# File 'lib/angry_shell.rb', line 136 def parent_after_fork! [write.first, read.last, error.last, exception.last].each {|fd| fd.close} self.write = write.last self.read = read.first self.error = error.first self.exception = exception.first end |