by carussell · 9y ago · 0 comments
ps a | grep "\<dd"
# [...]
kill -USR1 $YOUR_DD_PID
or pkill -USR1 ^dd
It also doesn't require you to get everything nailed down at the beginning. You've just spent the last 20 seconds waiting and realize you want a status update, but you didn't think to specify the option ahead of time? No problem.I've thought that dd's behavior could serve as a model for a new standard of interaction. Persistent progress indicators are known to cause performance degradation unless implemented carefully. And reality is, you generally don't need something to constantly report its progress even while you're not looking, anyway.
To figure out the ideal interaction, try modeling it after the conversation you'd have if you were talking to a person instead of your shell:
"Hey, how much longer is it going to take to flash that image?"
The way dd works is close to this scenario.
It's also worth noting the separate "progress" project which can be used to give the progress of running file based utilities.
We generally have pushed back on adding progress to each of the coreutils for these reasons, but the low overhead of implementation and high overlap with existing options was deemed enough to warrant adding this to dd
Ignored by the application, sure. But FreeBSD always prints useful stuff like load, current command, its pid and state:
$ dd if=/dev/random of=/dev/null
load: 0.72 cmd: dd 5820 [running] 0.70r 0.02u 0.68s 6% 2008k
263276+0 records in
263276+0 records out
134797312 bytes transferred in 0.708372 secs (190291809 bytes/sec)
(here, the "load:..." line is from the system, and the other 3 lines are from dd)
That seems to run substantial risk of seeing it in an inconsistent state, yeah?
Also I meant shm'd, not mmap'd.
Are you passing the reference to an mmap adress, or using the shm systemcalls? In what language are you programming in? Does race conditions endanger the shared memory? If so, how does using semaphores help?
Sorry, if I asked a lot of questions, feel free to answer any/none of them :)
Progress bars by default are also garbage if you are scripting and want to just log results. ffmpeg is terrible for this.
Are you referring to that npm progress bar thing a few months back? I'm pretty sure the reason for that can be summed up as "javascript, and web developers".
Anyway, he's not proposing progress bars by default, he's proposing a method by which you can query a process to see how far it's come. I think there's even a key combination to do this on FreeBSD.
Or, for example, you could write a small program that sends a USR1 signal every 5 seconds, splitting out the responsibility of managing a progress bar:
% progress cp bigfile /tmp/
And then the 'progress' program would draw you a text progress bar, or even pop up an X window with a progress bar.
pv image.img | dd of=/dev/rdisk2 bs=1M
This adds another pipe though. I don't know the effect this has on performance.