diff --git a/src/include/pv-internal.h b/src/include/pv-internal.h index ba9830c..d7f6491 100644 --- a/src/include/pv-internal.h +++ b/src/include/pv-internal.h @@ -201,6 +201,9 @@ struct pvstate_s { off_t size; /* total size of data */ unsigned int skip_errors; /* skip read errors counter */ int output_fd; /* fd to write output to */ + pid_t othermonitor_pid; /* pid of the other monitor, in "-M both" mode */ + int othermonitor_read_fd; /* fd to read transfer counts from other monitor */ + int othermonitor_write_fd; /* fd to write transfer counts to other monitor */ unsigned int average_rate_window; /* time window in seconds for average rate calculations */ unsigned int history_interval; /* seconds between each average rate calc history entry */ pvdisplay_width_t width; /* screen width */ diff --git a/src/include/pv.h b/src/include/pv.h index c7690c0..a8009ab 100644 --- a/src/include/pv.h +++ b/src/include/pv.h @@ -239,6 +239,7 @@ extern void pv_state_extra_display_set(pvstate_t, /*@null@*/ const char *); extern void pv_state_output_set(pvstate_t, int, const char *); extern void pv_state_average_rate_window_set(pvstate_t, unsigned int); extern void pv_state_set_terminal_supports_utf8(pvstate_t, bool); +extern void pv_state_othermonitor_set(pvstate_t, pid_t, int, int); extern void pv_state_inputfiles(pvstate_t, unsigned int, const char **); extern void pv_state_watchfds(pvstate_t, unsigned int, const pid_t *, const int *); diff --git a/src/main/main.c b/src/main/main.c index 7429f60..67e4a20 100644 --- a/src/main/main.c +++ b/src/main/main.c @@ -286,14 +286,7 @@ static int pv__store_and_forward(pvstate_t state, opts_t opts, bool can_have_eta * As a side effect, "command_fd" is closed. */ static int pv__run_monitor(const char *program_name, pvstate_t state, pvside_t side, int command_fd, - /*@unused@ */ - __attribute__((unused)) pid_t othermonitor_pid, - /*@unused@ */ - __attribute__((unused)) - int othermonitor_read_fd, - /*@unused@ */ - __attribute__((unused)) - int othermonitor_write_fd) + pid_t othermonitor_pid, int othermonitor_read_fd, int othermonitor_write_fd) { const char *dummy_argv[1]; /* flawfinder: ignore */ @@ -325,7 +318,7 @@ static int pv__run_monitor(const char *program_name, pvstate_t state, pvside_t s fprintf(stderr, "%s: %s\n", program_name, strerror(errno)); } - /* TODO: pass othermonitor_* into the state for ratio display. */ + pv_state_othermonitor_set(state, othermonitor_pid, othermonitor_read_fd, othermonitor_write_fd); /*@-observertrans@ */ dummy_argv[0] = "-"; diff --git a/src/main/options.c b/src/main/options.c index ead226e..cf85a6f 100644 --- a/src/main/options.c +++ b/src/main/options.c @@ -1290,6 +1290,7 @@ opts_t opts_parse(unsigned int argc, char **argv) opts->eta = true; opts->rate = true; opts->bytes = true; + /* TODO: add ratio format if "-M both" */ } /* If -Z was given but not -E, pretend one -E was given too. */ diff --git a/src/pv/display.c b/src/pv/display.c index 2c7a1ff..365b9b0 100644 --- a/src/pv/display.c +++ b/src/pv/display.c @@ -544,6 +544,7 @@ pvdisplay_bytecount_t pv_formatter_segmentcontent(char *content, pvformatter_arg { "{sgr:colour,...}", &pv_formatter_sgr, false }, { NULL, NULL, false } }; + /* TODO: formatter for ratio, for "-M both" */ return format_component_array; } diff --git a/src/pv/loop.c b/src/pv/loop.c index 776c832..5c82bc9 100644 --- a/src/pv/loop.c +++ b/src/pv/loop.c @@ -185,6 +185,10 @@ int pv_main_loop(pvstate_t state) unsigned int file_idx; bool output_is_pipe; + /* TODO: treat "-F ''" as "-q" so there's no extra blank line. */ + /* TODO: if "-q", turn off "-c", again so there's no blank line. */ + /* May need local no_display and cursor flags for this. */ + /* * "written" is ALWAYS bytes written by the last transfer. * @@ -338,6 +342,9 @@ int pv_main_loop(pvstate_t state) pv_elapsedtime_add_nsec(&next_remotecheck, REMOTE_INTERVAL); } + /* TODO: occasionally check othermonitor_read_fd, calculate ratio */ + /* TODO: occasionally send to othermonitor_write_fd */ + if (1 == state->flags.trigger_exit) break; diff --git a/src/pv/state.c b/src/pv/state.c index 2345576..81cba2c 100644 --- a/src/pv/state.c +++ b/src/pv/state.c @@ -191,6 +191,9 @@ pvstate_t pv_state_alloc(void) state->watchfd.count = 0; state->control.output_fd = -1; + state->control.othermonitor_pid = 0; + state->control.othermonitor_read_fd = -1; + state->control.othermonitor_write_fd = -1; #ifdef HAVE_IPC state->cursor.shmid = -1; state->cursor.pvcount = 1; @@ -769,6 +772,13 @@ void pv_state_set_terminal_supports_utf8(pvstate_t state, bool val) state->status.terminal_supports_utf8 = val; } +void pv_state_othermonitor_set(pvstate_t state, pid_t pid, int read_fd, int write_fd) +{ + state->control.othermonitor_pid = pid; + state->control.othermonitor_read_fd = read_fd; + state->control.othermonitor_write_fd = write_fd; +} + /* * Set the array of input files. */