How to prevent a user from using ctrl-c to stop a script?

后端 未结 1 1062
长发绾君心
长发绾君心 2021-01-13 04:15

I load a script in .bash_profile and this script will ask for right password whenever a user opens a terminal window. If the user enters a wrong code, the scrip

1条回答
  •  借酒劲吻你
    2021-01-13 05:11

    You can always trap SIGINT:

    trap 'echo got SIGINT' SIGINT
    

    Once you're done, reinstall the default handler again with

    trap SIGINT
    

    See the POSIX spec for trap for details. This works in all Bourne shells, not just bash.

    0 讨论(0)
提交回复
热议问题