4

I started a long running background-process (dd with /dev/urandom) in my ssh console. Later I had to disconnect. When I logged in, again (this time directly, without ssh), the process still seemed to to run.

I am not sure what happened - I did not use disown. When I logged in later, the process was not listed in top at first, but after a while it reclaimed a high CPU percentage, as I expected. So I assume dd is still running.

Now, I'd like to see the progress. I use kill -USR1 <pid> but nothing is printed. Is there any way to get the output again?

tanascius
  • 389
  • 1
  • 6
  • 15

4 Answers4

4

Redirecting all outputs (stdout, stdin, stderr) can disassociate a child process with the parent.

You can try attaching to the process with gdb, type 'c' for continue, and watch that console while you hup it from another.

gdb /bin/dd pid

kmarsh
  • 3,103
  • 15
  • 22
  • Thanks for your answer - `gdb` itself does not display the output :/ But I was able to restore my lost stderr with `gdb` - see my own answer for details. – tanascius Mar 22 '10 at 21:04
3

Thanks to kmarsh's answer and this threads I was able to redirect my lost output (stderr) to a file:

gdb /bin/dd 2616

(gdb) p creat("/root/dd.stderr",0600)
[Switching to Thread 0x7f651ece56e0 (LWP 2616)]
$1 = 3
(gdb) p dup2(3,2)
$2 = 2
(gdb) p close(3)
$3 = 0
(gdb) q

After running kill -USR1 2616 I can cat my new file:

631820341060 bytes (632 GB) copied, 81603.1 s, 7.7 MB/s
tanascius
  • 389
  • 1
  • 6
  • 15
2

i'm afraid not. but next time - use screen. google for tutorials or start here.

pQd
  • 29,561
  • 5
  • 64
  • 106
1

You might be able to see the output by looking in /proc/(pid of your dd/fd/1 or /proc/(pid)/fd/2. Cat that, then hit it with a USR1 and see if you get anything.

Bill Weiss
  • 10,782
  • 3
  • 37
  • 65