Support for backgrounding pv, and allowing it to be monitored separately

I would like to be able to use pv to monitor a background transfer and periodically check the current progress. At a glance, a combination of pv -q & and pv -R $! seems like it should do the job but fails on two accounts:

  1. pv -q & immediately stops, as it wants access to the terminal (even with -q)
  2. pv -R ... affects the behaviour of the first pv in its terminal, rather than showing the progress in the current terminal

(1) is demonstrable -- just running pv -q </dev/zero >/dev/null & ends up with a stopped job that only works when forgrounded with fg
(2) is demonstrable with help from screen or tmux -- running pv -q </dev/zero >/dev/null (no &) in one window and then running pv -R $(pidof -s pv) in a second does not display anything in the second window; while running pv -R $(pidof -s pv) -p starts writing output in the first window.

pv -d $(pidof pv) does not appear to help, I assume because the first pv already has the files open, so never "sees" a new open "event". Likewise pv -d "$(pidof pv):0" doesn't work, because the first pv has opened devices, not files (I am really hoping to monitor transfer between non-files, specifically stdout-to-fifo). I've also tried dd ... &; pv -d $(pidof dd), which suffers the same.

I suppose both pv -R and pv -d would also be limited to only having state information about the transfer since the second pv started, and would not have access to the time/byte-count/avg-rate of the running first pv.

As such, my enhancement request is twofold:

  1. ability to background a pv without it stopping for terminal access
  2. a specific switch, e.g. -M <pid>, to monitor (or mirror) the existing pv process indicated by <pid>, e.g by instructing the first process to IPC its transfer history to the second, and for the second to output to the terminal.
    • if a fifo-driven --redir-to / --redir-from semantic makes more sense than some other IPC, that would be fine

Note that I am not just hoping to solve the issue of backgrounding and checking in the same session -- I would hope/expect that implementing (1) would just allow CTRL+Z and judicious use of fg/bg for that purpose. I am also looking to have pv invoked somewhere else (e.g. by cron) and be able to attach to it for occasional progress updates by an operator. It just so happens that I need a long-running-writer | pv > /tmp/fifo & behaviour, so that something else can read the fifo.

(If any of this exists in the releases after 1.6.0, please advise/accept my apologies for the noise!)

I would like to be able to use `pv` to monitor a background transfer and periodically check the current progress. At a glance, a combination of `pv -q &` and `pv -R $!` seems like it should do the job but fails on two accounts: 1. `pv -q &` immediately stops, as it wants access to the terminal (even with `-q`) 2. `pv -R ...` affects the behaviour of the first `pv` in its terminal, rather than showing the progress in the current terminal (1) is demonstrable -- just running `pv -q </dev/zero >/dev/null &` ends up with a stopped job that only works when forgrounded with `fg` (2) is demonstrable with help from `screen` or `tmux` -- running `pv -q </dev/zero >/dev/null` (no `&`) in one window and then running `pv -R $(pidof -s pv)` in a second does not display anything in the second window; while running `pv -R $(pidof -s pv) -p` starts writing output in the first window. `pv -d $(pidof pv)` does not appear to help, I assume because the first `pv` already has the files open, so never "sees" a new open "event". Likewise `pv -d "$(pidof pv):0"` doesn't work, because the first `pv` has opened *devices*, not files (I am really hoping to monitor transfer between non-files, specifically stdout-to-fifo). I've also tried `dd ... &; pv -d $(pidof dd)`, which suffers the same. I suppose both `pv -R` and `pv -d` would also be limited to only having state information about the transfer since the *second* `pv` started, and would not have access to the time/byte-count/avg-rate of the running *first* `pv`. As such, my enhancement request is twofold: 1. ability to background a `pv` without it stopping for terminal access 2. a specific switch, e.g. `-M <pid>`, to *monitor* (or *mirror*) the existing `pv` process indicated by `<pid>`, e.g by instructing the first process to IPC its transfer history to the second, and for the second to output to the terminal. * if a fifo-driven `--redir-to` / `--redir-from` semantic makes more sense than some other IPC, that would be fine Note that I am not just hoping to solve the issue of backgrounding and checking in the *same* session -- I would hope/expect that implementing (1) would just allow <kbd>CTRL+Z</kbd> and judicious use of `fg`/`bg` for that purpose. I am also looking to have `pv` invoked somewhere *else* (e.g. by `cron`) and be able to *attach* to it for occasional progress updates by an operator. It just so happens that I need a `long-running-writer | pv > /tmp/fifo &` behaviour, so that something *else* can read the fifo. (If any of this exists in the releases after 1.6.0, please advise/accept my apologies for the noise!)