diff --git a/userspace/sinspui/cursesui.cpp b/userspace/sinspui/cursesui.cpp index 5182eafbca..c9361a7cba 100644 --- a/userspace/sinspui/cursesui.cpp +++ b/userspace/sinspui/cursesui.cpp @@ -279,6 +279,7 @@ sinsp_cursesui::sinsp_cursesui(sinsp* inspector, m_sorting_col = sorting_col; m_json_spy_renderer = NULL; m_json_spy_text_fmt = json_spy_text_fmt; + m_n_progress_reports = 0; #ifndef NOCURSESUI m_viz = NULL; diff --git a/userspace/sinspui/cursesui.h b/userspace/sinspui/cursesui.h index 5451ec0e8d..3a81d9bd78 100644 --- a/userspace/sinspui/cursesui.h +++ b/userspace/sinspui/cursesui.h @@ -637,7 +637,7 @@ class sinsp_cursesui { std::string jdata = m_json_spy_renderer->get_data(); double rprogress = m_inspector->get_read_progress(); - if(ts > m_1st_evt_ts || next_res == SCAP_EOF) + if(ts > m_1st_evt_ts || (next_res == SCAP_EOF && m_n_progress_reports > 0)) { // We add the comma only after the first progress status update. printf(","); @@ -646,15 +646,16 @@ class sinsp_cursesui rprogress, m_json_spy_renderer->get_count(), jdata.c_str()); + m_n_progress_reports++; fflush(stdout); + } - if(next_res != SCAP_EOF) - { - // We update the value only if we have - // an event. - m_last_progress_evt = evt->get_num(); - } + if(next_res != SCAP_EOF) + { + // We update the value only if we have + // an event. + m_last_progress_evt = evt->get_num(); } // @@ -826,5 +827,6 @@ class sinsp_cursesui int32_t m_sorting_col; json_spy_renderer* m_json_spy_renderer; sinsp_evt::param_fmt m_json_spy_text_fmt; + uint64_t m_n_progress_reports; };