I've created a little function for strace
'ing a set of the current user's processes by name:
function pstrace() {
local pattern="$1";
shift;
prefixDashP $(pgrep -U $(whoami) $pattern) | xargs strace -o /dev/stdout $@;
}
function prefixDashP() {
local new_args=();
for arg; do
new_args+=( '-p' );
new_args+=( "$arg" );
done;
for arg in "${new_args[@]}"; do
echo "$arg";
done;
}
# Usage: pstrace pattern1 pattern2 ...
The trouble is, if I accidentally specify too broad of a pattern, it tries to monitor processes that it shouldn't monitor, and so my system freezes.
Is there a list of processes that I can always exclude?