diff options
author | Lee Duncan <lduncan@suse.com> | 2019-10-10 13:46:36 -0700 |
---|---|---|
committer | Lee Duncan <lduncan@suse.com> | 2019-10-10 13:46:36 -0700 |
commit | f889c2dc80e7c18dea51d321ee3176d14c10d89d (patch) | |
tree | 9ca0d1a762772512e7624c7a3f1726276e9223a4 /daemon | |
parent | f9b54dda4a1193c1d8acd7422e64bbc2400d3875 (diff) | |
download | targetcli-f889c2dc80e7c18dea51d321ee3176d14c10d89d.tar.gz |
Close socket when receiving a signal to interrupt connection.
This allows the main loop to get an exception in its wait loop
when a signal arrives, rather than block forever. Before this,
topping the daemon required sending a KILL signal or sending one last
command, so that the loop could check the "received a signal" flag.
Diffstat (limited to 'daemon')
-rwxr-xr-x | daemon/targetclid | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/daemon/targetclid b/daemon/targetclid index 1265f30..7cec9f4 100755 --- a/daemon/targetclid +++ b/daemon/targetclid @@ -46,6 +46,7 @@ class TargetCLI: self.pid_file = '/var/run/targetclid.pid' self.NoSignal = True + self.sock = None # shell console methods self.shell = ConfigShell(getenv("TARGETCLI_HOME", '~/.targetcli')) @@ -101,6 +102,8 @@ class TargetCLI: signal handler ''' self.NoSignal = False + if self.sock: + self.sock.close() def try_pidfile_lock(self): @@ -212,6 +215,9 @@ def main(): to.display(to.render(err.strerror, 'red')) sys.exit(1) + # save socket so a signal can clean it up + to.sock = sock + # Bind the socket path try: sock.bind(to.socket_path) |