attaching to foreground process with strace in sh script
By katsumii on Jan 25, 2013
Apparently, it is not only the Oracle employees who use strace on foreground to process to get some info.
To find out how it is implemented, I have traced Oracle foreground processes.
Last week, I had to do same in shell script for trouble shooting. Here are the lines.
I think one can do same with dtrace or debugger.
#!/bin/bash ( sleep 3 ora_fg_pid=$(pgrep -P $(pgrep -P $$ sqlplus)) lsof -p $ora_fg_pid > /tmp/$ora_fg_pid.strace echo -e "\n= = = =strace begings here= = = =\n" >> /tmp/$ora_fg_pid.strace strace -fp $ora_fg_pid >> /tmp/$ora_fg_pid.strace 2>&1 ) & sqlplus -S scott/tiger <<EOF --Wait for strace to attach. execute user_lock.sleep(500) --Do real stuff. select * from dual / EOF