[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Trying to understand man page for dd



On 05/28/2017 07:40 AM, Thomas Schmitt wrote:
Hi,

Richard Owlett wrote:
It says in part:
    $ dd if=/dev/zero of=/dev/null& pid=$!
    $ kill -USR1 $pid; sleep 1; kill $pid
I think it is trying to tell me what I need to know.

dd is started as background process, busily copying bytes from nowhere
to nowhere:

  dd if=/dev/zero of=/dev/null &

Because of the ampersand "&", the shell prompt comes back immediately
after the command line is interpreted and performed. This line contains
the additional assignment of the new process id number to variable "pid":

  pid=$!

The first command in the second line then sends signal USR1 to the
process that is busily copying bytes in background:

  kill -USR1 $pid

This causes the output lines shown in the example

  18335302+0  records  in  18335302+0 records out 9387674624 bytes
  (9.4 GB) copied, 34.6279 seconds, 271 MB/s

The second command simply waits a second before it ends:

  sleep 1

The third command sends signal TERM to the dd process:

  kill $pid

which causes it to end without message.


In the full documentation at
  https://www.gnu.org/software/coreutils/manual/html_node/dd-invocation.html#dd-invocation
a paragraph near the page end gives a more detailed example:
  "Sending an ‘INFO’ signal (or ‘USR1’ signal where that is unavailable)
   to a running dd process makes it print I/O statistics to standard error
   ...
   # Output stats every second.
   ...
   "

Have a nice day :)

Thomas



*THANK YOU* !!!
I was closer to understanding it than I thought.
I've done a first read of the link you gave.
Not so much for this particular question, but in combination with your explanation it will lead to "grokking" some other things. [For non-R.A.Heinlein readers, see https://www.merriam-webster.com/dictionary/grok ;]



Reply to: