summaryrefslogtreecommitdiffstats
path: root/stap-serverd
diff options
context:
space:
mode:
authorFrank Ch. Eigler <fche@elastic.org>2008-08-06 12:06:06 -0400
committerFrank Ch. Eigler <fche@elastic.org>2008-08-06 12:06:06 -0400
commit3c4371661f144c331dd55ee6be8dab57ec2323c8 (patch)
tree217ccf5864840f14670138b592d90eceacc75fa3 /stap-serverd
parent44ab6f3be72e7b5eeaa2514cea0553b87007ee9c (diff)
parent0317fad416059781b7a152296c1d8b5a012bf925 (diff)
downloadsystemtap-steved-3c4371661f144c331dd55ee6be8dab57ec2323c8.tar.gz
systemtap-steved-3c4371661f144c331dd55ee6be8dab57ec2323c8.tar.xz
systemtap-steved-3c4371661f144c331dd55ee6be8dab57ec2323c8.zip
Merge commit 'origin/master' into pr4225
* commit 'origin/master': Use relative instead of absolute line. (bug 6611) move post-0.7 news tidbit to the top Add test for $$vars, $$params, $$locals. typographical tweaks for embedded script code Add $$vars, $$parms, $$locals Rename $path to $pathname of syscall tapset for 2.6.27 Correct several tests for 2.6.27 c code generation: assert C indentation/nesting cancels out at appropriate points Tweak test_installcheck for helloworld.meta and traceio2.meta. Run both tests for installcheck tests. No need for random suffix file cmdline and sysinfo files in the Ensure that a systemtap server is available if 'server' is specified session.h (struct systemtap_session): Added itrace_derived_probe * syscalls2.stp: Add sys_unlinkat. Fix on_each_cpu() call for kernels >2.6.26. Remove unused STAPCONF_MODULE_NSECTIONS
Diffstat (limited to 'stap-serverd')
-rwxr-xr-xstap-serverd28
1 files changed, 21 insertions, 7 deletions
diff --git a/stap-serverd b/stap-serverd
index eaaeda00..af4b2717 100755
--- a/stap-serverd
+++ b/stap-serverd
@@ -13,8 +13,8 @@
# incoming connections. When a connection is detected, the stap-server script
# is run to handle the request.
-# Catch ctrl-c
-trap 'handle_sigint' SIGINT
+# Catch ctrl-c and other termination signals
+trap 'terminate' SIGTERM SIGINT
#-----------------------------------------------------------------------------
# Helper functions.
@@ -61,7 +61,10 @@ function listen {
# Loop forever accepting requests
while true
do
- nc -l $port < $fifo_name | stap-server $((port + 1)) > $fifo_name 2>&1
+ # Run this in the background and wait for it. This way any signals
+ # received (i.e. SIGTERM) will be processed.
+ nc -l $port < $fifo_name | stap-server $((port + 1)) > $fifo_name 2>&1 &
+ wait %nc
done
}
@@ -74,13 +77,24 @@ function fatal {
exit 1
}
-# function: handle_sigint
+# function: terminate
#
-# Terminate gracefully when SIGINT is received.
-function handle_sigint {
- echo "$0: received SIGINT. Exiting."
+# Terminate gracefully.
+function terminate {
+ echo "$0: Exiting"
+
+ # Kill the running 'avahi-publish-service' job
+ kill -s SIGTERM %avahi-publish-service 2> /dev/null
+ wait %avahi-publish-service 2> /dev/null
+
+ # Kill any running 'nc -l' job.
+ kill -s SIGTERM "%nc -l" 2> /dev/null
+ wait "%nc - l" 2> /dev/null
+
+ # Clean up
cd `dirname $tmpdir`
rm -fr $tmpdir
+
exit
}