diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2019-12-26 18:29:55 +0100 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2019-12-26 18:29:55 +0100 |
commit | 7b3611a0d3a158dc44c1be8fd60e75cc6d937ef0 (patch) | |
tree | 797d6740de47a24a64d25dbbd1f944398a555f20 | |
parent | e490f5f4efbdeb4ac69bc18690050d5059229e22 (diff) |
inform the user if we did not saw the file was fully read/written but the pid is not available anymore
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
-rw-r--r-- | progressbar.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/progressbar.c b/progressbar.c index 93bf5ac..3224e91 100644 --- a/progressbar.c +++ b/progressbar.c @@ -699,9 +699,9 @@ int main(int argc, char ** argv) int print_len = finfo.terminal_output.printable_chars + finfo.terminal_output.unprintable_chars; - assert(print_len + 1 <= sizeof finfo.terminal_output.buf); + assert(print_len + 1 <= (int)sizeof(finfo.terminal_output.buf)); assert(finfo.terminal_output.buf[print_len] == '\0'); - assert(print_len == strlen(finfo.terminal_output.buf)); + assert(print_len == (int)strlen(finfo.terminal_output.buf)); assert(finfo.terminal_output.buf[0] == '\r' || finfo.terminal_output.buf[0] == '\n'); @@ -709,6 +709,24 @@ int main(int argc, char ** argv) fflush(stdout); nsleep(150000000L); } + /* Program exited!? We do not know if the file was fully read/written. Tell the user. */ + if (finfo.current_position < finfo.max_size) { + reset_terminal_output_buffer(&finfo); + if (term.dimensions_changed) { + term.dimensions_changed = 0; + finfo.terminal_output.buf[0] = '\n'; + } + + show_positions(&term, &finfo); + show_rate(&term, &finfo); + add_printable_buf(&term, &finfo, "[%s]", "PROGRAM EXITED!"); + show_progressbar(&term, &finfo); + fillup_remaining(&term, &finfo); + int print_len = finfo.terminal_output.printable_chars + + finfo.terminal_output.unprintable_chars; + printf("%.*s", print_len, finfo.terminal_output.buf); + fflush(stdout); + } puts(""); while (paths) { |