I have a script that should catch SIGTERM and SIGTSTP. This is what I have in the main block:
trap 'killHandling' TERM
And in function:
killHandling () { echo received kill signal, ignoring return }
... and similar for SIGINT. The problem is the user interface. The script asks the user for some input, and if SIGTERM or SIGINT occurs when the script is waiting for input, it is confusing. Here is the result in this case:
Enter something:
I definitely saw scripts that handle this more elegantly, for example:
Enter something:
What is the mechanism used to execute the latter? Unfortunately, I cannot just change my trap code to execute a second prompt, as the script offers the user a few things and what the hint says depends on the context. And there has to be a better way than writing context-sensitive trap functions.
I would really appreciate any pointers. Thanks!
source share