Trap Ctrl-C in a Bash script

How to trap Ctrl-C in a Bash script?

asked Jul 23, 2013 by anonymous

1 Answer

Best answer

The piece of code:

# trap ctrl-c and call ctrl_c()
trap ctrl_c INT

function ctrl_c() {
    echo "Ctrl-C by user"
    # do the jobs
answered Jul 23, 2013 by anonymous

Please log in or register to answer this question.

Copyright © SysTutorials. User contributions licensed under cc-wiki with attribution required.
Hosted on Dreamhost