attaching to foreground process with strace in sh script

Apparently, it is not only the Oracle employees who use strace on foreground to process to get some info.

 

Locks, Latches, Mutexes and CPU usage | The Pythian Blog

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



Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today