When exiting from 'purity', the terminal is left in a bad state. Ctrl+C does no longer work to cancel the command line and the prompt in 'rm -i' does not echo characters, and needs me to press Ctrl+J instead of Enter to confirm. The reason is that 'purity' uses a signed short instead of the adequate type, tcflag_t, for saving the tcsetattr flags that it restores later. Since bit 15 is set in my case, when expanded to unsigned, the high bits are all set, setting all kinds of unwanted flags that cause the above behaviour. The attached patch solves it.