def GetProcessPid(idx):
    pinfo = idaapi.process_info_t()
    pid = idaapi.get_process_info(idx, pinfo)
    if pid != idaapi.NO_PROCESS:
        return pinfo.pid
    else:
        return 0
Get the process ID of a running process
dataset/ETHPy150Open EiNSTeiN-/idapython/python/idc.py/GetProcessPid