Debian Codegraph @

doc/SystemTap_Beginners_Guide/testsuite/systemtap.base/stapsh.stp

raw
1 global kill_pid
2
3 probe begin {
4 println(pp())
5
6 // Print our process chain, should be stapio, stapsh, stap
7 t = task_current()
8 while (t && task_parent(t) != t) {
9 name = task_execname(t)
10 println("^ ", name)
11 if (name == "stap") {
12 // Remember this pid for killing later
13 kill_pid = task_pid(t)
14 break
15 }
16 t = task_parent(t)
17 }
18 }
19
20 probe timer.s(1) {
21 if (kill_pid) {
22 println(pp())
23
24 // Kill our stap pid, and it should be propagated back
25 // through stapsh to end this script.
26 system(sprint("/bin/kill -INT ", kill_pid))
27 kill_pid = 0
28 }
29 }
30
31 probe timer.s(10) {
32 println(pp())
33 println("timeout!")
34 exit()
35 }
36
37 probe end {
38 println(pp())
39 }