aboutsummaryrefslogtreecommitdiffhomepage
path: root/proc.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-04-25 13:26:56 -0700
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-04-25 13:26:56 -0700
commit17e815348b0352a9b2d7082f195bc5a51c698591 (patch)
tree8257c6958335e3532013a09e2f1dce640b266913 /proc.cpp
parent953ab4b3cfea1e3d77b0c768cdcc7cead6bb806b (diff)
Fix to drain command output from quit commands before returning from job_continue
This should fix the bug where output from commands and builtins gets incorrectly interleaved. I think this is a very long-standing bug that predates my work on the shell
Diffstat (limited to 'proc.cpp')
-rw-r--r--proc.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/proc.cpp b/proc.cpp
index e6cc4ab2..6d642eb6 100644
--- a/proc.cpp
+++ b/proc.cpp
@@ -1057,9 +1057,15 @@ void job_continue (job_t *j, int cont)
got_signal = 0;
quit = job_is_stopped( j ) || job_is_completed( j );
}
-
- while( got_signal && !quit )
- ;
+ while (got_signal && !quit);
+
+ if (quit) {
+ // It's possible that the job will produce output and exit before we've even read from it.
+ // We'll eventually read the output, but it may be after we've executed subsequent calls
+ // This is why my prompt colors kept getting screwed up - the builtin echo calls
+ // were sometimes having their output combined with the set_color calls in the wrong order!
+ read_try(j);
+ }
if( !quit )
{