File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -86,7 +86,7 @@ def close
8686 return unless state == :open
8787
8888 @state = :closing
89- sleep 0.01 until state == :closed
89+ sleep 0.001 until state == :closed
9090 end
9191
9292 # Return the write end of the pipe so that data can be written to it
@@ -149,6 +149,8 @@ def fileno
149149 # @api private
150150 #
151151 def write ( data )
152+ raise IOError , 'closed stream' unless state == :open
153+
152154 pipe_writer . write ( data )
153155 end
154156
@@ -289,7 +291,7 @@ def monitor_pipe
289291 @state = :closing
290292 end
291293 rescue IO ::WaitReadable
292- pipe_reader . wait_readable ( 0.01 )
294+ pipe_reader . wait_readable ( 0.001 )
293295 end
294296
295297 # Read any remaining data from the pipe and close it
Original file line number Diff line number Diff line change 166166 expect { monitored_pipe . write ( 'world' ) } . to raise_error ( IOError , 'closed stream' )
167167 end
168168 end
169+
170+ context 'after the pipe is closed' do
171+ it 'should raise an exception' do
172+ monitored_pipe . close
173+ expect { monitored_pipe . write ( 'hello' ) } . to raise_error ( IOError , 'closed stream' )
174+ end
175+ end
169176 end
170177end
You can’t perform that action at this time.
0 commit comments