17 Aug 2016
Note: The
dtracesecurity restrcition needs to be disabled on El Capitan. Boot into recovery mode →csrutil enable --without dtrace.
Capture stdout
sudo dtrace -p <$PID> -qn 'syscall::write*:entry /pid == $target && arg0 == 1/ { printf("%s", copyinstr(arg1, arg2)); }'
Capture stderr
sudo dtrace -p <$PID> -qn 'syscall::write*:entry /pid == $target && arg0 == 2/ { printf("%s", copyinstr(arg1, arg2)); }'
Capture both
sudo dtrace -p <$PID> -qn 'syscall::write*:entry /pid == $target && (arg0 == 1 || arg0 == 2)/ { printf("%s", copyinstr(arg1, arg2)); }'

Comments
Nothing yet. Say the first thing.
Sign in to join the conversation.