Monday, July 20, 2015

Bash and eternal sleep

I was trying to write a script to run a couple of background processes then wait for an interrupt signal from the keyboard. There's a nice way to do this with waits, but an even shorter way (if you have GNU -- i.e. almost all Linux machines) is:

function shutdown() {
# do stuff
}

trap shutdown INT
sleep inf