Skip to content

Instantly share code, notes, and snippets.

@alexeiz
Created July 25, 2017 17:21
Show Gist options
  • Save alexeiz/044179abb6e82843792987cc30f001cd to your computer and use it in GitHub Desktop.
Save alexeiz/044179abb6e82843792987cc30f001cd to your computer and use it in GitHub Desktop.
List affinities of process threads
#!/usr/bin/env bash
set -euo pipefail
[[ $# == 0 || $1 == '-h' ]] && {
bn=$(basename $0)
echo "$bn: list affinities of process threads"
echo "usage: $bn [pid|-p name]"
exit
}
pid=$1; shift
[[ $pid == '-p' ]] && {
pid=$(pgrep $1 | head -n1)
}
ps --no-headers -Tp $pid | \
perl -alne '$ts=`taskset -cp $F[1]`; $ts=~s/.*list: (.*)/$1/; chomp $ts; print "$_ $ts"' | \
column -t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment