summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rwxr-xr-xstap-client51
-rw-r--r--testsuite/ChangeLog6
-rw-r--r--testsuite/lib/systemtap.exp7
4 files changed, 66 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index d6226d2d..6ea7dc32 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2008-08-13 Dave Brolley <brolley@redhat.com>
+
+ * stap-client: Trap SIGTERM and SIGINT.
+ (unpack_response): chown of the systemtap temp directory before
+ we move it and only if we didn't create it.
+ (maybe_call_staprun): Check $e_script when determining whether a
+ script was specified. Provide the -c option to staprun. Run staprun
+ in the background and wait for it.
+ (terminate,interupt): New functions.
+
2008-08-11 Wenji Huang <wenji.huang@oracle.com>
* tapsets.cxx : Fixed compilation warning on gcc 3.x.
diff --git a/stap-client b/stap-client
index 405692f1..b6664bc3 100755
--- a/stap-client
+++ b/stap-client
@@ -16,6 +16,10 @@
# request. If a kernel module is generated, this script will load the module
# and execute it using 'staprun', if requested.
+# Catch ctrl-c and other termination signals
+trap 'terminate' SIGTERM
+trap 'interrupt' SIGINT
+
#-----------------------------------------------------------------------------
# Helper functions.
#-----------------------------------------------------------------------------
@@ -472,11 +476,11 @@ function unpack_response {
sed -i "s,^Keeping temporary directory.*,Keeping temporary directory \"$local_tmpdir_stap\"," $tmpdir_server/stderr
tmpdir_stap=$local_tmpdir_stap
else
+ # Make sure we own the systemtap temp directory if we are root.
+ test $EUID = 0 && chown $EUID:$EUID $tmpdir_server/$tmpdir_stap
+ # The temp directory will be moved to here below.
tmpdir_stap=`pwd`/$tmpdir_stap
fi
-
- # Make sure we own the systemtap temp directory if we are root.
- test $EUID = 0 && chown $EUID:$EUID $tmpdir_stap
fi
# Move the contents of the server's tmpdir down one level to the
@@ -568,7 +572,7 @@ function maybe_call_staprun {
# There should be a systemtap temporary directory.
if test "X$tmpdir_stap" = "X"; then
# OK if no script specified
- if test "X$script_file" != "X"; then
+ if test "X$e_script" != "X" -o "X$script_file" != "X"; then
fatal "ERROR: systemtap temporary directory is missing in server response"
fi
return
@@ -582,13 +586,26 @@ function maybe_call_staprun {
if test $p_phase = 5; then
# We have a module. Try to run it
+ # If a -c command was specified, pass it along.
+ if test "X$c_cmd" != "X"; then
+ staprun_opts="-c '$c_cmd'"
+ fi
+
+ # The -v level will be one less than what was specified
+ # for us.
for ((--v_level; $v_level > 0; --v_level))
do
staprun_opts="$staprun_opts -v"
done
- PATH=`staprun_PATH` staprun $staprun_opts \
- $tmpdir_stap/`ls $tmpdir_stap | grep '.ko$'`
+
+ # Run it in the background and wait for it. This
+ # way any signals send to us can be caught.
+ PATH=`staprun_PATH` eval staprun "$staprun_opts" \
+ $tmpdir_stap/`ls $tmpdir_stap | grep '.ko$'` &
+ wait %?staprun
rc=$?
+ # 127 from wait means that the job was already finished.
+ test $rc=127 && rc=0
fi
fi
}
@@ -655,6 +672,28 @@ function cleanup {
fi
}
+# function: terminate
+#
+# Terminate gracefully.
+function terminate {
+ # Clean up
+ echo "$0: terminated by signal"
+ cleanup
+
+ # Kill any running staprun job
+ kill -s SIGTERM %?staprun
+
+ exit 1
+}
+
+# function: interrupt
+#
+# Pass an interrupt (ctrl-C) to staprun
+function interrupt {
+ # Pass the signal on to any running staprun job
+ kill -s SIGINT %?staprun
+}
+
#-----------------------------------------------------------------------------
# Beginning of main line execution.
#-----------------------------------------------------------------------------
diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog
index 405dd754..ed11d429 100644
--- a/testsuite/ChangeLog
+++ b/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2008-08-13 Dave Brolley <brolley@redhat.com>
+
+ * lib/systemtap.exp (setup_systemtap_environment): client_path is now
+ global.
+ (systemtap_exit): Remove the directory named by $client_path.
+
2008-08-11 Frank Ch. Eigler <fche@elastic.org>
* systemtap.base/vars.exp: Adjust to loss of "\n" at end of $$vars
diff --git a/testsuite/lib/systemtap.exp b/testsuite/lib/systemtap.exp
index 8b533303..28129f0a 100644
--- a/testsuite/lib/systemtap.exp
+++ b/testsuite/lib/systemtap.exp
@@ -37,7 +37,7 @@ proc print_systemtap_version {} {
proc setup_systemtap_environment {} {
- global srcdir prefix env server_pid
+ global srcdir prefix env server_pid client_path
# need an absolute SRCDIR for the top-level src/ tree
# XXX: or, we could change nearby uses of ${SRCDIR}/testsuite to ${SRCDIR}
@@ -121,7 +121,7 @@ proc systemtap_init {args} {}
proc systemtap_version {} {}
proc systemtap_exit {} {
- global server_pid
+ global server_pid client_path
# Stop the stap server, if we started it.
if {[use_server_p]} then {
@@ -129,6 +129,9 @@ proc systemtap_exit {} {
print "Stopping the systemtap server with PID==$server_pid"
exec stap-stop-server $server_pid
}
+
+ # Remove the temporary stap script
+ exec /bin/rm -fr $client_path
}
}