nitrokey-app2 icon indicating copy to clipboard operation
nitrokey-app2 copied to clipboard

add signal handling

Open jj-so opened this issue 1 year ago • 3 comments

If you start the application from a terminal and press the key combination ctrl+c in this terminal, the application will now be closed.

Closes #132

jj-so avatar Jan 29 '24 16:01 jj-so

nice, looks good, can you explain why this works now?

daringer avatar Jan 29 '24 16:01 daringer

The signal.signal() function can be used to define your own handlers that are executed when a signal is received.

SIGINT is a standard handler that translates a keyboard interrupt

SIG_DFL ensures that ctrl+c is recognized to close the program

jj-so avatar Jan 29 '24 16:01 jj-so

ok, also crosschecked SIG_DFL which essentially tells the kernel to handle SIGINT as is - which means that qt6 is disabling this behavior by default - ok, why not ;)

on the other side, I could test this successfully - think this should be good for now.

Could we also disable this behavior during runtime ? Means, as of now one could likely kill the nitrokeyapp during an update operation, which would brick the device - I am not sure if we should introduce this if this could happen...

daringer avatar Jan 29 '24 17:01 daringer