Add an handler for SIGINT to cleanly logout. - anticapum - Handle Università Politecnica delle Marche captive portal
(HTM) hg clone https://bitbucket.org/iamleot/anticapum
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
---
(DIR) changeset 8730e43dcd1657b17a530a585febaf29e5288931
(DIR) parent 7df20da8c8da77e7e2ccec9e75f795b576ee478c
(HTM) Author: Leonardo Taccari <iamleot@gmail.com>
Date: Mon, 19 Mar 2018 11:36:49
Add an handler for SIGINT to cleanly logout.
Honor SIGINT in order to logout from the current captive portal session and
exit.
Diffstat:
anticapum.py | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
---
diff -r 7df20da8c8da -r 8730e43dcd16 anticapum.py
--- a/anticapum.py Fri Jan 12 11:39:53 2018 +0100
+++ b/anticapum.py Mon Mar 19 11:36:49 2018 +0100
@@ -147,9 +147,15 @@
print('sid:', s.get('sid', ''))
print('pulsante:', s.get('pulsante', ''))
+ def sigint_handler(signum, frame):
+ if s:
+ logout(s)
+ exit(0)
+
if hasattr(signal, 'SIGINFO'):
signal.signal(signal.SIGINFO, siginfo_handler)
signal.signal(signal.SIGUSR1, siginfo_handler)
+ signal.signal(signal.SIGINT, sigint_handler)
username, password = credential()