Last active
February 16, 2017 08:59
-
-
Save liaoyw/a7b1684caad84e7824867c193fba5bbe to your computer and use it in GitHub Desktop.
close deleted file fd
This file contains 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
# gdb -ex 'set print thread-events off' --batch -q -x ~/df.py | |
import os | |
import os.path | |
import sys | |
import gdb | |
pid = open('/var/run/docker.pid', 'r').read() | |
print 'attach to ' + pid | |
gdb.execute('attach ' + pid) | |
os.chdir('/proc/%s/fd'%pid) | |
out=[] | |
for f in os.listdir('.'): | |
if not os.path.islink(f): | |
continue | |
if '(deleted)' in os.readlink(f): | |
#with open(f, 'w') as of: | |
#of.truncate(0) | |
out.append(gdb.execute('call close(%d)'%int(f), to_string=True)) | |
print len(out) | |
gdb.execute('detach') | |
gdb.execute('quit') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment