Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Firstly find the PID of the process:
- $ ps aux|grep cat
- rjc 6760 0.0 0.0 1580 376 pts/5 S+ 15:31 0:00 cat
- Now check the file handles it has open:
- $ ls -l /proc/6760/fd
- total 3
- lrwx—— 1 rjc rjc 64 Feb 27 15:32 0 -> /dev/pts/5
- l-wx—— 1 rjc rjc 64 Feb 27 15:32 1 -> /tmp/foo1
- lrwx—— 1 rjc rjc 64 Feb 27 15:32 2 -> /dev/pts/5
- Now run GDB:
- $ gdb -p 6760 /bin/cat
- GNU gdb 6.4.90-debian
- Copyright (C) 2006 Free Software Foundation, Inc
- [lots more license stuff snipped]
- Attaching to program: /bin/cat, process 6760
- [snip other stuff that's not interesting now]
- (gdb) p close(1)
- $1 = 0
- (gdb) p creat(“/tmp/foo3″, 0600)
- $2 = 1
- (gdb) q
- The program is running. Quit anyway (and detach it)? (y or n) y
- Detaching from program: /bin/cat, process 6760
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement