I want to get the PIDs of a given process name and attach to their outputs with strace. I can do this manually like so:
$ pidof foobar
1234 2345
$ strace -p1234 -p2345 -s9999 -e write
Great! But I want to automate this from Ansible, so I need to do both these steps in Bash i.e. without the manual conversion of the two numeric PIDs to two -p
arguments.
I've tried a lot of things like creating an array from the PIDs and trying to join the array with -p
but once it gets this complex you need to create a function and I don't have a lot of scope for that with an Ansible one-liner.
Thanks!