Tom, enclosing the program in a loop doesn't sound like a very good solution. I've done some research and it seems that Ubuntu sends SIGTERM to all programs before shutting down. Since the script should trap SIGTERM and clean up before exiting, I don't know what's going wrong.
I'm not sure what you mean about the backup image - the original image is restored fine when I kill the program with SIGINT [ Ctrl + C ].
Tom, enclosing the program in a loop doesn't sound like a very good solution. I've done some research and it seems that Ubuntu sends SIGTERM to all programs before shutting down. Since the script should trap SIGTERM and clean up before exiting, I don't know what's going wrong.
I'm not sure what you mean about the backup image - the original image is restored fine when I kill the program with SIGINT [ Ctrl + C ].