'Display various info from /proc/pid/
Usage:
MYNAME [pid]'

def procinfo(self, *arg):

    options = ['exe', 'fd', 'pid', 'ppid', 'uid', 'gid']
    if (peda.getos() != 'Linux'):
        warning_msg('this    command    is    only    available    on    Linux')
    (pid,) = normalize_argv(arg, 1)
    if (not pid):
        pid = peda.getpid()
    if (not pid):
        return
    info = {}
    try:
        info['exe'] = os.path.realpath(('/proc/%d/exe' % pid))
    except:
        warning_msg(('cannot    access    /proc/%d/' % pid))
        return
    info['fd'] = {}
    fdlist = os.listdir(('/proc/%d/fd' % pid))
    for fd in fdlist:
        rpath = os.readlink(('/proc/%d/fd/%s' % (pid, fd)))
        sock = re.search('socket:\\[(.*)\\]', rpath)
        if sock:
            spath = execute_external_command(('netstat    -aen    |    grep    %s' % sock.group(1)))
            if spath:
                rpath = spath.strip()
        info['fd'][to_int(fd)] = rpath
    info['pid'] = pid
    status = open(('/proc/%d/status' % pid)).read()
    ppid = re.search('PPid:\\s*([^\\s]*)', status).group(1)
    info['ppid'] = (to_int(ppid) if ppid else (-1))
    uid = re.search('Uid:\\s*([^\n]*)', status).group(1)
    info['uid'] = [to_int(id) for id in uid.split()]
    gid = re.search('Gid:\\s*([^\n]*)', status).group(1)
    info['gid'] = [to_int(id) for id in gid.split()]
    for opt in options:
        if (opt == 'fd'):
            for (fd, path) in info[opt].items():
                msg(('fd[%d]    ->    %s' % (fd, path)))
        else:
            msg(('%s    =    %s' % (opt, info[opt])))
    return
