Skip to content

Instantly share code, notes, and snippets.

@rockuw
Forked from zaius/background.sh
Created March 30, 2018 01:46
Show Gist options
  • Select an option

  • Save rockuw/54a98f018785134707b3100339354264 to your computer and use it in GitHub Desktop.

Select an option

Save rockuw/54a98f018785134707b3100339354264 to your computer and use it in GitHub Desktop.
How to redirect a running process output to a file and log out
ctrl-z
bg
touch /tmp/stdout
touch /tmp/stderr
gdb -p $!
# In GDB
p dup2(open("/tmp/stdout", 1), 1)
p dup2(open("/tmp/stderr", 1), 2)
detach
quit
# Back in shell
disown
logout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment