Tuesday, February 7, 2012

Trap Ctrl C in Bash

#!/bin/bash

# call trapped in case Ctrl+C pressed
trap trapped INT

function trapped() {
    echo "CTRL-C pressed"
}

while true; do
    sleep 1
    echo -n "."
done

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.