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

Re: Trying to understand man page for dd



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


Reply to: