diff --git a/dist/tools/pyterm/pyterm b/dist/tools/pyterm/pyterm index a7e77526b9..13088b37d5 100755 --- a/dist/tools/pyterm/pyterm +++ b/dist/tools/pyterm/pyterm @@ -675,10 +675,6 @@ class PytermClientFactory(ReconnectingClientFactory): reason) -def __stop_reactor(signum, stackframe): - sys.stderr.write("Ctrl-C is disabled, type '/exit' instead\n") - - class fdsocket(socket.socket): def read(self, bufsize): return self.recv(bufsize) @@ -758,13 +754,15 @@ if __name__ == "__main__": args.log_dir_name, args.newline, args.format, args.prompt) myshell.prompt = '' - if args.server and args.tcp_port: - myfactory = PytermClientFactory(myshell) - reactor.connectTCP(args.server, args.tcp_port, myfactory) - myshell.factory = myfactory - reactor.callInThread(myshell.cmdloop, "Welcome to pyterm!\n" - "Type '/exit' to exit.") - signal.signal(signal.SIGINT, __stop_reactor) - reactor.run() - else: - myshell.cmdloop("Welcome to pyterm!\nType '/exit' to exit.") + try: + if args.server and args.tcp_port: + myfactory = PytermClientFactory(myshell) + reactor.connectTCP(args.server, args.tcp_port, myfactory) + myshell.factory = myfactory + reactor.callInThread(myshell.cmdloop, "Welcome to pyterm!\n" + "Type '/exit' to exit.") + reactor.run() + else: + myshell.cmdloop("Welcome to pyterm!\nType '/exit' to exit.") + except KeyboardInterrupt: + myshell.do_PYTERM_exit(None)