aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2010-12-01 23:24:31 -0500
committerGlenn Elliott <gelliott@cs.unc.edu>2010-12-01 23:24:31 -0500
commiteb18b073e8b04819efdd2b57595bc6e1ee7bc4b6 (patch)
treedd74ed5cd682a08a41e96f595e808db8b81021bf
parente84fce96e96d8b5ee5e9531400b0735fb7e4fbb6 (diff)
Feature: Make st_trace controllable by signals.
This patch makes the st_trace script controllable by SIGUSR1. This is useful for integrating tracing into an automated script since st_trace previously was controlled by human input ("Press Enter to end tracing..."). The old method is still used by default. Use '-s' to make st_trace wait for SIGUSR1 to terminate tracing instead. Note that you can send SIGUSR1 to st_trace with the following example commands: > pkill -SIGUSR1 st_trace > kill -SIGUSR1 <PID for st_trace>
-rwxr-xr-xst_trace35
1 files changed, 31 insertions, 4 deletions
diff --git a/st_trace b/st_trace
index 35b6efc..7a46ae6 100755
--- a/st_trace
+++ b/st_trace
@@ -1,5 +1,26 @@
1#!/bin/bash 1#!/bin/bash
2 2
3if [ "$1" == "-s" ]
4then
5 AUTO=1
6 shift
7fi
8
9PIDS=""
10
11# signal that we're done gathering data and clean up
12on_finish()
13{
14 echo "Ending Trace..."
15 kill $PIDS
16 wait $PIDS
17
18 exit 0
19}
20
21# register shutdown signal handler
22trap 'on_finish' SIGUSR1
23
3[ -z "$FTCAT" ] && FTCAT=ftcat 24[ -z "$FTCAT" ] && FTCAT=ftcat
4[ -z "$FTDEV" ] && FTDEV=/home/litmus/log 25[ -z "$FTDEV" ] && FTDEV=/home/litmus/log
5 26
@@ -21,7 +42,13 @@ do
21 echo $! "> $TARGET [$?]" 42 echo $! "> $TARGET [$?]"
22done 43done
23 44
24echo "Press Enter to end tracing..." 45if [[ $AUTO != 1 ]]
25read 46then
26kill $PIDS 47 echo "Press Enter to end tracing..."
27wait $PIDS 48 read
49 on_finish
50else
51 # wait for SIGUSR1 to terminate
52 echo "Waiting for SIGUSR1 to end tracing..."
53 while [ 1 ]; do sleep 10; done
54fi