Support for backgrounding pv, and allowing it to be monitored separately #56
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ivarch/pv#56
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I would like to be able to use
pvto monitor a background transfer and periodically check the current progress. At a glance, a combination ofpv -q &andpv -R $!seems like it should do the job but fails on two accounts:pv -q &immediately stops, as it wants access to the terminal (even with-q)pv -R ...affects the behaviour of the firstpvin 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 withfg(2) is demonstrable with help from
screenortmux-- runningpv -q </dev/zero >/dev/null(no&) in one window and then runningpv -R $(pidof -s pv)in a second does not display anything in the second window; while runningpv -R $(pidof -s pv) -pstarts writing output in the first window.pv -d $(pidof pv)does not appear to help, I assume because the firstpvalready has the files open, so never "sees" a new open "event". Likewisepv -d "$(pidof pv):0"doesn't work, because the firstpvhas opened devices, not files (I am really hoping to monitor transfer between non-files, specifically stdout-to-fifo). I've also trieddd ... &; pv -d $(pidof dd), which suffers the same.I suppose both
pv -Randpv -dwould also be limited to only having state information about the transfer since the secondpvstarted, and would not have access to the time/byte-count/avg-rate of the running firstpv.As such, my enhancement request is twofold:
pvwithout it stopping for terminal access-M <pid>, to monitor (or mirror) the existingpvprocess 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.--redir-to/--redir-fromsemantic makes more sense than some other IPC, that would be fineNote 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/bgfor that purpose. I am also looking to havepvinvoked somewhere else (e.g. bycron) and be able to attach to it for occasional progress updates by an operator. It just so happens that I need along-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!)
Note, the backgrounding issue may be as simple as redirecting stderr to /dev/null, e.g.
pv </dev/zero >/dev/null 2>/dev/null &.Monitoring that from a separate session is still an issue...
This is a use case that I'd not considered but I can see where it would be handy.
It sounds a little similar to issue #54 "Run command every n percent", in which the suggestion is to send a desktop notification every now and then - but not quite the same.
Yes I would see it being implemented as "pv --quiet < bigfile | bigprogram > outputfile &" and then "pv --query " to see how it's getting on.
Not sure specifically how it would be implemented, but IPC is probably plausible.
yes, but i want to see stderr of pv in my terminal
this is blocking the background process, which is not expected, so its a bug in pv
expected behavior
this shows no output from pv
writing stderr of pv to a tempfile works with
pv -fwhy? im using pv to debug parallel processing
pv shouldn't block when run in the background, so that's a bug, but as you'll find when you do "
bg" after "echo x | pv -r | cat >/dev/null &", pv will run in the background happily but will never write any progress information to the terminal when it's not in the foreground. This is by design.Strangely, "
echo x | pv -r | cat >/dev/null &" stops immediately and will then complete when told to "bg", but "echo x | pv -r >/dev/null &" will run in the background and complete normally without stopping.This is when I test with the current git code as it is today.
Having more than one pv instance writing to the terminal in the background doesn't seem like it will work very well. Maybe with "
-c" it could work, but I'm not sure.It looks like we've got a few issues rolled into one here.
Running "
pv </dev/zero >/dev/null &" no longer stops, but adding pipes like "pv </dev/zero | cat >/dev/null &" starts to behave strangely, so I think that signal handling relating to terminal I/O is a bit wrong.It would be useful to be able to show the progress of some other pv, such as "
pv --query 12345" to show what the pv process 12345 would output if it was on this terminal.It would be useful to be able to run multiple pv instances at once on the same terminal in separate pipelines.
Would a "
-ff" option to force output even when not controlling the terminal (i.e. when in the background) be of any use here?The backgrounding issue is fixed in the latest commit.
I will close this issue and have raised a separate one (#101) about being able to query the progress of one PV from another.