如何在linux中查找父进程ID

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9707114/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 05:11:35  来源:igfitidea点击:

How to find parent process id in linux

linux

提问by user509755

I was looking for a linux command to find the parent process id. When I use the following command ps- ef | grep jboos

我正在寻找一个 linux 命令来查找父进程 ID。当我使用以下命令 ps-ef | grep jboos

It returns all process ids including chile and some other information. What I am looging for is to filter out child ids and other information and return only parent id. So that calling app can kill all the running processes by just killing parent.

它返回所有进程 ID,包括智利和其他一些信息。我正在寻找的是过滤掉子 ID 和其他信息并仅返回父 ID。这样调用应用程序就可以通过杀死父进程来杀死所有正在运行的进程。

Thanks

谢谢

回答by Ed Heal

getppidis the function that you require. In bash it is $PPID

getppid是您需要的功能。在 bash 中它是$PPID

eg

例如

#!/bin/bash

echo $PPID;

回答by kclair

The l(lowercase L) option to pswill add the PPID column to the output.

l(小写L)选项ps将PPID列添加到输出。