diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2010-12-01 23:24:31 -0500 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2010-12-01 23:24:31 -0500 |
commit | eb18b073e8b04819efdd2b57595bc6e1ee7bc4b6 (patch) | |
tree | dd74ed5cd682a08a41e96f595e808db8b81021bf | |
parent | e84fce96e96d8b5ee5e9531400b0735fb7e4fbb6 (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-x | st_trace | 35 |
1 files changed, 31 insertions, 4 deletions
@@ -1,5 +1,26 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/bash |
2 | 2 | ||
3 | if [ "$1" == "-s" ] | ||
4 | then | ||
5 | AUTO=1 | ||
6 | shift | ||
7 | fi | ||
8 | |||
9 | PIDS="" | ||
10 | |||
11 | # signal that we're done gathering data and clean up | ||
12 | on_finish() | ||
13 | { | ||
14 | echo "Ending Trace..." | ||
15 | kill $PIDS | ||
16 | wait $PIDS | ||
17 | |||
18 | exit 0 | ||
19 | } | ||
20 | |||
21 | # register shutdown signal handler | ||
22 | trap '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 [$?]" |
22 | done | 43 | done |
23 | 44 | ||
24 | echo "Press Enter to end tracing..." | 45 | if [[ $AUTO != 1 ]] |
25 | read | 46 | then |
26 | kill $PIDS | 47 | echo "Press Enter to end tracing..." |
27 | wait $PIDS | 48 | read |
49 | on_finish | ||
50 | else | ||
51 | # wait for SIGUSR1 to terminate | ||
52 | echo "Waiting for SIGUSR1 to end tracing..." | ||
53 | while [ 1 ]; do sleep 10; done | ||
54 | fi | ||