chiark / gitweb /
bin/outbound: Factor out the actual shutting down of an SSH process.
authorMark Wooding <mdw@distorted.org.uk>
Wed, 6 May 2015 17:04:28 +0000 (18:04 +0100)
committerMark Wooding <mwooding@good.com>
Wed, 6 May 2015 17:04:28 +0000 (18:04 +0100)
bin/outbound

index cad152660dc5ac315d63ea961574579b995b3b06..5ed160df9c5a425ad10ded7e68ec96b745d19463 100755 (executable)
@@ -15,12 +15,7 @@ writefile () {
 
 runssh () { ssh -T -oControlPath="./$host.ctrl" "$@"; }
 
-stopit () {
-
-  ## Initial shutdown protocol.
-  writefile "$host.state" stopping
-  if [ -f "$host.pid" ]; then kill $(cat "$host.pid") 2>/dev/null || :; fi
-  rm -f "$host.pid"
+clobber () {
 
   ## Shut down an existing connection if there is one.
   if [ -S "$host.ctrl" ]; then
@@ -39,6 +34,17 @@ stopit () {
     ## Remove the stale socket.
     rm -f "$host.ctrl"
   fi
+}
+
+stopit () {
+
+  ## Initial shutdown protocol.
+  writefile "$host.state" stopping
+  if [ -f "$host.pid" ]; then kill $(cat "$host.pid") 2>/dev/null || :; fi
+  rm -f "$host.pid"
+
+  ## Clobber the existing connection, if there is one.
+  clobber
 
   ## Update the state.
   rm -f "$host.state" "$host.pid"