「top」が「xargs」で実行されないのはなぜですか?

「top」が「xargs」で実行されないのはなぜですか?

top-pオプションと複数のPIDを使用して実行しようとしています。xargs。ただし、top実行に失敗してエラーが発生しますtop: failed tty get

$ pgrep gvfs | paste -s -d ',' | xargs -t top -p
top -p 1598,1605,1623,1629,1635,1639,1645,1932,2744
top: failed tty get

実行される完全なコマンドを表示するには、-tオプションを使用します。xargsビューは良く見え、手動で正常に実行できます。

top -p 1598,1605,1623,1629,1635,1639,1645,1932,2744

しかし、では実行されませんxargs。なぜそんなことですか?

ベストアンサー1

対話型アプリケーション--open-ttyの場合(例:xargstopmanxargs:

   -o, --open-tty
          Reopen stdin as /dev/tty in the child process before
          executing the command.  This is useful if you want xargs
          to run an interactive application.

実行するコマンドは次のようにtopする必要があります。

pgrep gvfs | paste -s -d ',' | xargs --open-tty top -p

おすすめ記事