technology

using strace on multiple processes in linux

My distinguished and decidedly sexy colleague Josh Barratt recently noted that you can use multiple -p flags with strace in order to simultaneously attach to multiple process. This is very useful when you’re trying to debug something like Nginx where there are likely multiple child processes that you want to monitor. If this is something that you think you might find useful, here’s a bash snippet that will make an easy to use straceall command: function straceall { strace $(pidof “${1}” | sed ‘s/\([0-9]*\)/-p \1/g’) } Just put this in your .bashrc, and then you can easily monitor a family of processes with a command such as: straceall php5-fpm if you’re trying to debug say a PHP issue.

Navigate