Linux – close file descriptors without killing process

-- get list of file descriptors

# lsof /dev/mapper/XYZ_*

-- example output
oracle    31814 oracle  256u   BLK  253,7      0t0 20968 /dev/mapper/../dm-7

-- above, fd 256 is open for update (could also be w (write))

-- attach to process with gdb debugger
# gdb -p 31814

-- close file descriptor(s)
gdb> p close(256)

Leave a Reply

Your email address will not be published. Required fields are marked *