Last active
August 29, 2015 14:13
-
-
Save enxebre/9628d6b28165d61bf116 to your computer and use it in GitHub Desktop.
gdb_redirect_ouput
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # From /dev/null to file | |
| gdb -p processpid | |
| (gdb) call creat("/home/me/myprog.stdout",0600) | |
| $1 = 7 | |
| (gdb) call dup2(7,1) | |
| $2 = 1 | |
| (gdb) call creat("/home/me/myprog.stderr",0600) | |
| $3 = 8 | |
| (gdb) call dup2(8,2) | |
| $4 = 2 | |
| # From somewhere to /dev/null | |
| (gdb) p dup2(open("/dev/null", 0), 1) | |
| (gdb) p dup2(open("/dev/null", 0), 2) | |
| (gdb) detach | |
| (gdb) quit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment