diff options
author | Dave Brolley <brolley@redhat.com> | 2008-07-29 13:40:08 -0400 |
---|---|---|
committer | Dave Brolley <brolley@redhat.com> | 2008-07-29 13:40:08 -0400 |
commit | 0e47827d5f461ceb0e67540adba7bc2fe3a360da (patch) | |
tree | 804fe937a06c7ee71ec6d438d8d8bf6d1a70f32d /stap-serverd | |
parent | b1af668d224b0673f27f991a77455d6e0ecb6891 (diff) | |
download | systemtap-steved-0e47827d5f461ceb0e67540adba7bc2fe3a360da.tar.gz systemtap-steved-0e47827d5f461ceb0e67540adba7bc2fe3a360da.tar.xz systemtap-steved-0e47827d5f461ceb0e67540adba7bc2fe3a360da.zip |
Ensure that a systemtap server is available if 'server' is specified
in EXTRA_TOOL_OPTS for 'make check' and 'make installcheck'
Diffstat (limited to 'stap-serverd')
-rwxr-xr-x | stap-serverd | 28 |
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 } |