获取兄弟姐妹的PID

Getting PIDs of siblings

我正在从另一个 bash 脚本(父)中启动几个并行的 bash 脚本(兄弟)。我如何最好地在这些脚本中获取其他兄弟姐妹的 PID?

我可以得到的父进程

ps -p $$ -o ppid --no-heading

但我不知道如何获取它的子进程。

尝试ps --ppid <parent-process-id>(或)pgrep -P <parent-process-id>

来自 ps

man

--ppid pidlist Select by parent process ID. This selects the processes with a parent process ID in pidlist. That is, it selects processes that are children of those listed in pidlist.

对于pgrep

-P ppid,... Only match processes whose parent process ID is listed.