def ancestors(pid):
"""ancestors(pid) -> int list
Arguments:
pid (int): PID of the process.
Returns:
List of PIDs of whose parent process is `pid` or an ancestor of `pid`.
"""
pids = []
while pid != 0:
pids.append(pid)
pid = parent(pid)
return pids
评论列表
文章目录