win32console.GetConsoleProcessList

(int,...) = GetConsoleProcessList()

Returns pids of all processes attached to current console