Bug #9040 » readline_fix.patch
ChangeLog | ||
---|---|---|
Mon Oct 21 21:19:34 2013 Eamonn Webster <eamonn.webster@gmail.com>
|
||
* ext/readline/readline.c: Always close the file as we dup'ed the descriptor
|
||
* test/readline/test_readline.rb: Assign a 10,000 times shouldn't run out of handles
|
||
Fri Oct 18 15:23:34 2013 Koichi Sasada <ko1@atdot.net>
|
||
* gc.c: change terminology of heap.
|
ext/readline/readline.c | ||
---|---|---|
static void
|
||
clear_rl_instream(void)
|
||
{
|
||
rb_io_t *ifp;
|
||
if (rl_instream) {
|
||
if (readline_instream) {
|
||
rb_io_check_initialized(ifp = RFILE(rb_io_taint_check(readline_instream))->fptr);
|
||
if (ifp->fd < 0 || fileno(rl_instream) == ifp->fd) {
|
||
fclose(rl_instream);
|
||
rl_instream = NULL;
|
||
}
|
||
fclose(rl_instream);
|
||
}
|
||
readline_instream = Qfalse;
|
||
rl_instream = NULL;
|
||
... | ... | |
static void
|
||
clear_rl_outstream(void)
|
||
{
|
||
rb_io_t *ofp;
|
||
if (rl_outstream) {
|
||
if (readline_outstream) {
|
||
rb_io_check_initialized(ofp = RFILE(rb_io_taint_check(readline_outstream))->fptr);
|
||
if (ofp->fd < 0 || fileno(rl_outstream) == ofp->fd) {
|
||
fclose(rl_outstream);
|
||
rl_outstream = NULL;
|
||
}
|
||
fclose(rl_outstream);
|
||
}
|
||
readline_outstream = Qfalse;
|
||
rl_outstream = NULL;
|
test/readline/test_readline.rb | ||
---|---|---|
end
|
||
end
|
||
def test_close_streams
|
||
assert_equal(10000, 10000.times{ Readline.input = STDIN })
|
||
end
|
||
def test_closed_outstream
|
||
bug5803 = '[ruby-dev:45043]'
|
||
IO.pipe do |r, w|
|