by shigemk2

当面は技術的なことしか書かない

プロセスの親子関係 ps axf vs pstree

プロセスの親子関係を知りたいのでそういうコマンドを試してみたかった。

ps axf

ps の f オプション / マスタカの ChangeLog メモ

これはMacOSXでは使えませんでした。こちらはCentOSでの実行結果。

9999  ?        Ss     0:08 /usr/sbin/httpd
11111 ?        Sl     0:01  \_ /usr/sbin/httpd
22222 ?        Sl     0:01  \_ /usr/sbin/httpd
33333 ?        Sl     0:01  \_ /usr/sbin/httpd
44444 ?        Sl     0:01  \_ /usr/sbin/httpd
55555 ?        Sl     0:01  \_ /usr/sbin/httpd

pstree

pstreeコマンド(実行中のプロセスのツリー形式表示)

MacOSXでは、pstreeというものが使えます。
homebrewでインストールできます。

$ pstree | grep httpd 
|-+= 00019 root /usr/sbin/httpd -D FOREGROUND
 | |--- 00020 _www /usr/sbin/httpd -D FOREGROUND
 | |--- 00021 _www /usr/sbin/httpd -D FOREGROUND
 | |--- 00022 _www /usr/sbin/httpd -D FOREGROUND
 | |--- 00023 _www /usr/sbin/httpd -D FOREGROUND
 | \--- 00024 _www /usr/sbin/httpd -D FOREGROUND