aboutsummaryrefslogtreecommitdiffstats
path: root/input.c
diff options
context:
space:
mode:
authorJari Aalto <jari.aalto@cante.net>2005-12-07 14:08:12 +0000
committerJari Aalto <jari.aalto@cante.net>2009-09-12 16:46:57 +0000
commit95732b497d12c98613bb3c5db16b61f377501a59 (patch)
tree5e1cdf79eb0407e09dca4c0ec29e11442c7d1d15 /input.c
parenteb87367179effbe5f430236db8259006d71438b7 (diff)
downloadandroid_external_bash-95732b497d12c98613bb3c5db16b61f377501a59.tar.gz
android_external_bash-95732b497d12c98613bb3c5db16b61f377501a59.tar.bz2
android_external_bash-95732b497d12c98613bb3c5db16b61f377501a59.zip
Imported from ../bash-3.1.tar.gz.
Diffstat (limited to 'input.c')
-rw-r--r--input.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/input.c b/input.c
index c4f335d..314a1f5 100644
--- a/input.c
+++ b/input.c
@@ -50,7 +50,7 @@ extern int errno;
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
@@ -312,7 +312,13 @@ duplicate_buffered_stream (fd1, fd2)
(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;