if a signal is received. */
static char localbuf[128];
-static int local_index, local_bufused;
+static int local_index = 0, local_bufused = 0;
/* Posix and USG systems do not guarantee to restart read () if it is
interrupted by a signal. We do the read ourselves, and restart it
(bash_input.location.buffered_fd == fd2);
if (buffers[fd2])
- free_buffered_stream (buffers[fd2]);
+ {
+ /* If the two objects share the same b_buffer, don't free it. */
+ if (buffers[fd1] && buffers[fd1]->b_buffer && buffers[fd1]->b_buffer == buffers[fd2]->b_buffer)
+ buffers[fd2] = (BUFFERED_STREAM *)NULL;
+ else
+ free_buffered_stream (buffers[fd2]);
+ }
buffers[fd2] = copy_buffered_stream (buffers[fd1]);
if (buffers[fd2])
buffers[fd2]->b_fd = fd2;