lsofコマンドが利用できない場合、特定のpidのアクティブなunixドメインソケットをどのように取得しますか?

lsofコマンドが利用できない場合、特定のpidのアクティブなunixドメインソケットをどのように取得しますか?

lsofを使用する権限がない場合は、既知のプロセスのpidをどのように取得しますか?ありがとう

コマンドがアクティブなUnixドメインソケットを印刷していることを知っていますが、netstat -l -p更新されていないようですか?ソケットが閉じた後も、netstatコマンドの結果に表示され続けます。

ベストアンサー1

/procLinuxでは、特定のPIDの下でファイルシステムを具体的に検索できます/proc/<pid>/fd。各プロセスのすべてのファイル記述子(fd)がここにリストされています。

はい

$ ls -l /proc/27634/fd/
total 0
lrwx------ 1 root root 64 Mar 17 20:09 0 -> /dev/null
lrwx------ 1 root root 64 Mar 17 20:09 1 -> /dev/null
lrwx------ 1 root root 64 Mar 17 20:10 10 -> /dev/ptmx
lrwx------ 1 root root 64 Mar 17 20:10 12 -> /dev/ptmx
lrwx------ 1 root root 64 Mar 17 20:10 13 -> /dev/ptmx
lrwx------ 1 root root 64 Mar 17 20:09 2 -> /dev/null
lr-x------ 1 root root 64 Mar 17 20:09 3 -> socket:[430396]
l-wx------ 1 root root 64 Mar 17 20:09 4 -> socket:[430437]
lrwx------ 1 root root 64 Mar 17 20:09 5 -> pipe:[430440]
l-wx------ 1 root root 64 Mar 17 20:10 6 -> pipe:[430440]
lrwx------ 1 root root 64 Mar 17 20:10 7 -> socket:[430443]
lrwx------ 1 root root 64 Mar 17 20:10 8 -> socket:[430444]
lrwx------ 1 root root 64 Mar 17 20:10 9 -> socket:[430446]

そこにリストされているすべてはsocket:[....]ソケットです。

おすすめ記事