mmgen-xmrwallet: force-kill wallet daemon on double Ctrl-C

This commit is contained in:
The MMGen Project 2023-05-01 15:49:39 +00:00
commit 6620db4158
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
4 changed files with 11 additions and 6 deletions

View file

@ -194,6 +194,8 @@ class Daemon(Lockable):
if self.state == 'ready':
if not silent:
msg(f'Stopping {self.desc} on port {self.bind_port}')
if self.force_kill:
run(['sync'])
ret = self.run_cmd(self.stop_cmd,silent=True)
if self.pids:

View file

@ -163,8 +163,5 @@ if cfg.autosign and not cfg.test_suite:
m = op_cls(cfg, xmrwallet_uargs(infile, wallets, spec))
try:
if async_run(m.main()):
m.post_main()
except KeyboardInterrupt:
ymsg('\nUser interrupt')
if async_run(m.main()):
m.post_main()

View file

@ -88,6 +88,7 @@ class MoneroWalletDaemon(RPCDaemon):
new_console_mswin = True
networks = ('mainnet','testnet')
rpc_ports = _nw(13131, 13141, None) # testnet is non-standard
_reset_ok = ('debug','wait','pids','force_kill')
def __init__(
self,

View file

@ -867,7 +867,12 @@ class MoneroWalletOps:
async def stop_wallet_daemon(self):
if not self.cfg.no_stop_wallet_daemon:
await self.c.stop_daemon()
try:
await self.c.stop_daemon()
except KeyboardInterrupt:
ymsg('\nForce killing wallet daemon')
self.c.daemon.force_kill = True
self.c.daemon.stop()
def get_wallet_fn(self,data,watch_only=None):
if watch_only is None: