Get list of socket inodes for process pid.
(pid)
| 26 | # STATE_CLOSING = '0B' |
| 27 | |
| 28 | def get_socket_inodes(pid): |
| 29 | ''' |
| 30 | Get list of socket inodes for process pid. |
| 31 | ''' |
| 32 | base = '/proc/%i/fd' % pid |
| 33 | inodes = [] |
| 34 | for item in os.listdir(base): |
| 35 | target = os.readlink(os.path.join(base, item)) |
| 36 | if target.startswith('socket:'): |
| 37 | inodes.append(int(target[8:-1])) |
| 38 | return inodes |
| 39 | |
| 40 | def _remove_empty(array): |
| 41 | return [x for x in array if x !=''] |