def getProcessName(pid):
    """Gets process name from process id"""
    truncProcessName = open('/proc/%s/status' % pid).readline()[6:-1]
    processName = truncProcessName
    line = open('/proc/%s/cmdline' % pid).readline()
    parts = line.split('\x00')
    for part in parts:
        cmdName = part.split('/')[-1]
        if cmdName.startswith(truncProcessName):
            processName = cmdName
    return processName
