Skip to content

Instantly share code, notes, and snippets.

@jim3ma
Forked from zaius/background.sh
Created March 14, 2017 07:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jim3ma/239d6257f715d6ea91f630426ea01021 to your computer and use it in GitHub Desktop.
Save jim3ma/239d6257f715d6ea91f630426ea01021 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